#問題点
Windows10の環境にRubyをインストールして、動作確認を一通りした後にプログラムを動かしてみたのですが、tkが入っていなかったので、tkをインストールしようとしたらできませんでした。
#やったこと
- gem install tk の実行
だいたいのサイトではgem install tkだけで動くようなことを書いているのですが、下のようなエラーが出てしまいます。
rb
1Temporarily enhancing PATH for MSYS/MINGW... 2Installing required msys2 packages: mingw-w64-x86_64-tk 3警告: mingw-w64-x86_64-tk-8.6.9.1-1 は最新です -- スキップ 4Building native extensions. This could take a while... 5ERROR: Error installing tk: 6 ERROR: Failed to build gem native extension. 7 8 current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tk-0.2.0/ext/tk 9C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190204-13668-e0wcil.rb extconf.rb 10check functions.checking for ruby_native_thread_p() in ruby.h... yes 11checking for rb_errinfo() in ruby.h... yes 12checking for rb_safe_level() in ruby.h... yes 13checking for rb_hash_lookup() in ruby.h... yes 14checking for rb_proc_new() in ruby.h... yes 15checking for rb_obj_untrust() in ruby.h... yes 16checking for rb_obj_taint() in ruby.h... yes 17checking for rb_set_safe_level_force() in ruby.h... yes 18checking for rb_sourcefile() in ruby.h... yes 19checking for rb_thread_alive_p() in ruby.h... no 20checking for rb_thread_check_trap_pending() in ruby.h... yes 21checking for ruby_enc_find_basename() in ruby.h... yes 22*** extconf.rb failed *** 23Could not create Makefile due to some reason, probably lack of necessary 24libraries and/or headers. Check the mkmf.log file for more details. You may 25need configuration options. 26 27Provided configuration options: 28 --with-opt-dir 29 --without-opt-dir 30 --with-opt-include 31 --without-opt-include=${opt-dir}/include 32 --with-opt-lib 33 --without-opt-lib=${opt-dir}/lib 34 --with-make-prog 35 --without-make-prog 36 --srcdir=. 37 --curdir 38 --ruby=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME) 39 --enable-shared 40 --disable-shared 41 --with-tk-old-extconf 42 --without-tk-old-extconf 43 --with-tk-old-extconf 44 --without-tk-old-extconf 45 --with-ActiveTcl 46 --without-ActiveTcl 47 --with-tk-shlib-search-path 48 --without-tk-shlib-search-path 49 --with-tcltkversion 50 --without-tcltkversion 51 --with-tcl-build-dir 52 --without-tcl-build-dir 53 --with-tk-build-dir 54 --without-tk-build-dir 55 --with-tcl-config 56 --without-tcl-config 57 --with-tk-config 58 --without-tk-config 59 --with-tclConfig-dir 60 --without-tclConfig-dir 61 --with-tkConfig-dir 62 --without-tkConfig-dir 63 --with-tclConfig-file 64 --without-tclConfig-file 65 --with-tkConfig-file 66 --without-tkConfig-file 67 --with-tcllib 68 --without-tcllib 69 --with-tklib 70 --without-tklib 71 --with-tcl-dir 72 --without-tcl-dir 73 --with-tk-dir 74 --without-tk-dir 75 --with-tcl-include 76 --without-tcl-include 77 --with-tk-include 78 --without-tk-include 79 --with-tcl-lib 80 --without-tcl-lib 81 --with-tk-lib 82 --without-tk-lib 83 --with-tcltk-framework 84 --without-tcltk-framework 85 --with-tcl-framework-dir 86 --without-tcl-framework-dir 87 --with-tk-framework-dir 88 --without-tk-framework-dir 89 --with-tcl-framework-header 90 --without-tcl-framework-header 91 --with-tk-framework-header 92 --without-tk-framework-header 93 --with-X11 94 --without-X11 95 --with-X11-dir 96 --without-X11-dir 97 --with-X11-include 98 --without-X11-include 99 --with-X11-lib 100 --without-X11-lib 101 --enable-tcltk-stubs 102 --disable-tcltk-stubs 103 --enable-tcl-h-ver-check 104 --disable-tcl-h-ver-check 105 --enable-tk-h-ver-check 106 --disable-tk-h-ver-check 107 --enable-mac-tcltk-framework 108 --disable-mac-tcltk-framework 109 --enable-tcltk-framework 110 --disable-tcltk-framework 111 --enable-pthread 112 --disable-pthread 113 --enable-tcl-thread 114 --disable-tcl-thread 115 --enable-space-on-tk-libpath 116 --disable-space-on-tk-libpath 117 --with-tcl-build-dir 118 --without-tcl-build-dir 119 --with-tk-build-dir 120 --without-tk-build-dir 121 --with-tcltkversion 122 --without-tcltkversion 123 --with-ActiveTcl 124 --without-ActiveTcl 125 --enable-space-on-tk-libpath 126 --disable-space-on-tk-libpath 127 --enable-tcltk-stubs 128 --disable-tcltk-stubs 129 --with-tcltk-stubs 130 --without-tcltk-stubs 131 --with-tcl-dir 132 --without-tcl-dir 133 --with-tcl-include 134 --without-tcl-include=${tcl-dir}/include 135 --with-tcl-lib 136 --without-tcl-lib=${tcl-dir}/lib 137 --with-tk-dir 138 --without-tk-dir 139 --with-tk-include 140 --without-tk-include=${tk-dir}/include 141 --with-tk-lib 142 --without-tk-lib=${tk-dir}/lib 143 --with-tclConfig-file 144 --without-tclConfig-file 145 --with-tkConfig-file 146 --without-tkConfig-file 147 --with-tclConfig-dir 148 --without-tclConfig-dir 149 --with-tkConfig-dir 150 --without-tkConfig-dir 151extconf.rb:408:in `=~': invalid byte sequence in UTF-8 (ArgumentError) 152 from extconf.rb:408:in `!~' 153 from extconf.rb:408:in `block in parse_tclConfig' 154 from extconf.rb:406:in `foreach' 155 from extconf.rb:406:in `parse_tclConfig' 156 from extconf.rb:812:in `block (2 levels) in search_tclConfig' 157 from extconf.rb:807:in `each' 158 from extconf.rb:807:in `block in search_tclConfig' 159 from extconf.rb:773:in `each' 160 from extconf.rb:773:in `search_tclConfig' 161 from extconf.rb:964:in `get_tclConfig' 162 from extconf.rb:1967:in `<main>' 163Use ActiveTcl libraries (if available). 164Search tclConfig.sh and tkConfig.sh. 165To see why this extension failed to compile, please check the mkmf.log which can be found here: 166 167 C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/tk-0.2.0/mkmf.log 168 169extconf failed, exit code 1 170 171Gem files will remain installed in C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tk-0.2.0 for inspection. 172Results logged to C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/tk-0.2.0/gem_make.out
また、このエラーを読み解くとextconf.rbの408行目にエラーが発生しているとのことなので、
C:\Ruby25-x64\lib\ruby\gems\2.5.0\gems\tk-0.2.0\ext\tk\extconf.rbを展開してみました。
rb
1def parse_tclConfig(file) 2 # check tclConfig.sh/tkConfig.sh 3 tbl = Hash.new{|h,k| h[k] = ""} 4 return tbl unless file 5 IO.foreach(file){|line| 6 line.strip! 7 next if line !~ /^([^\#=][^=]*)=(['"]|)(.*)\2$/ # ⇐ここが408行目 8 key, val = $1, $3 9 tbl[key] = val.gsub(/$\{([^}]+)\}/){|s| 10 subst = $1 11 (tbl[subst])? tbl[subst]: s 12 } rescue nil 13 } 14 tbl 15end
このような関数が置かれており、408行目には正規表現が書かれていました。見たところ、正規表現に誤りはなさそうに見受けられるので、もう一つのエラー要因であるutf-8に原因があるのかと、当該ファイルをsjisにしてみてからgem install tkとしましたが、やはり同じエラーが出ます。
また、既に0.2.0というものが入っているので、$gem uninstall tkとしてみたら、tkというファイルはありませんと注意されます。フォルダ内で消してみても、全く効果がありませんでした。
Ruby2.5以上ではtkはWindows64ビット機では使えないのでしょうか?判定お願いします。もし、普通にインストールできたという人は、何が問題か指摘してもらえるとありがたいです。
使えなければ、VMのLinux環境でもRubyとRailsを動かせるようにしているので、そちらでテストを試そうと思っています。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/20 02:50
2019/02/20 22:27
2019/02/22 10:24 編集