質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

2回答

899閲覧

ruby2.5.3でtkを動かせない

FKM

総合スコア3633

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2019/02/04 12:00

編集2019/02/04 12:04

#問題点
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を動かせるようにしているので、そちらでテストを試そうと思っています。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ベストアンサー

Ruby Installerのruby 2.6.1p33でインストールできることを確認しました。

エラーから考えられるに、コマンドプロンプトがCP932であるため、処理の途中での設定ファイル読み込みもCP932でおこなってしまうが、実際はそれはUTF-8であったため、おかしなバイト文字列が出来てしまったと考えられます。ですので、コマンドプロンプトもUTF-8にすることで治る可能性があります。

解決方法として、コマンドプロンプト上で

chcp 65001

と打って、コマンドプロンプトをUTF-8にしてからインストールしてみてください。それで通るかも知れません。

  • ActiveTcl は完全にアンインストールしておいてください。そちらのTkライブラリを見に行くとおかしくなる可能性があります。(tkライブラリはMSYS2環境にインストールされます)
  • 書き替えたファイルは全て元に戻してください。よくわからないなら、アンインストール+インストール先フォルダ(C:\Ruby25-x64)削除、再インストールとしてください。
  • 2.5でだめなら2.6を試して見てください。

なお、Rubyインストール時に常にUTF-8環境にするかのチェックボックスがあると思います。コマンドプロンプトも常にUTF-8にしないと動作がおかしくなる場合がありますので、チェックの有無にかかわらず、UTF-8環境で実施してみてください。

投稿2019/02/19 22:27

raccy

総合スコア21735

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

FKM

2019/02/20 02:50

ありがとうございます。言われたとおりに全部削除してから、入れ直してみましたが 相変わらず同じエラーメッセージが表示されてしまいます。
raccy

2019/02/20 22:27

後考えられるのはtkConfig.shかtclConfig.shが壊れているぐらいです。MSYS2環境が別枠ならそちらも入れ直すぐらいでしょうか。それとActiveTcl以外にもTcl/Tkが入っている可能性でしょうか。ちょっとお手上げです。
FKM

2019/02/22 10:24 編集

ありがとうございます、MAPサーバーにTclが入っているため、そっちと干渉している可能性が高いです。 こっちは業務上消せないし、まあ、これ以上Windowsでtkを動かそうとは思っていない(Railsは入る) ので、打ち切ります。 色々調べていただきありがとうございました。ですが、証明できたことは Windows10でもRubyのtkは入る ということですね。
guest

0

To see why this extension failed to compile, please check the mkmf.log which can be found here:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/tk-0.2.0/mkmf.log

「なぜコンパイルに失敗したか知りたければ、mkmf.log をチェックしろ」とあるので、確認してみれば何か分かるかもしれません。

投稿2019/02/04 12:41

kts_h

総合スコア207

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

FKM

2019/02/05 03:16 編集

ありがとうございます。そこも一応調べてみてはおり、以下の「ある関数が宣言されていない」というエラーが出て、その原因も調べてみたのですが答えが見つかりませんでした。 conftest.c:17:57: error: 'rb_thread_alive_p' undeclared (first use in this function); did you mean 'rb_thread_sleep'? int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_alive_p; return !p; } "x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -march=x86-64 -mtune=generic -O2 -pipe conftest.c -L. -LC:/Ruby25-x64/lib -L. -pipe -s -lx64-msvcrt-ruby250 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " D:\Users\admin\AppData\Local\Temp\ccOPHa4h.o:conftest.c:(.text+0x5): undefined reference to `rb_thread_alive_p' collect2.exe: error: ld returned 1 exit status また、別環境のWindows64で同じように入れると、そちらは普通にインストールできたので、2.5.3だからという理由ではないこともわかったのですが、なぜこのPCだと失敗するのかがわからない状況です。 また、gem install rails とすると、そっちは普通に入り、なぜtkだけ失敗するのかわかりません
kts_h

2019/02/05 03:52

何らかの理由で `rb_thread_alive_p` という C 言語で書かれた関数が行方不明になっているのが原因のようです。
FKM

2019/02/05 05:41

ありがとうございます。どこのファイル内のものなのでしょうか。
FKM

2019/02/06 00:42

ActiveTCLが入っていなかったのでダウンロードして再実行してみたところ、エラーメッセージが以下のように変わりました。見つかったけど、使えないという警告が出ていたので、TCLのバージョンを8.5.1と最新版の8.6.8で試してみたのですが、同じエラーメッセージが出ています。このshファイルをRuby配下のある場所に入れるたら動いたというLinuxでの報告はありますが、Windowsと構造が違うので、その場所が見つけられずに困っています。 Use ActiveTcl libraries (if available). Search tclConfig.sh and tkConfig.sh. WARNING: found "c:/Tcl/lib/tclConfig-shared.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "c:/Tcl/lib/tkConfig-shared.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. WARNING: found "c:/Tcl/lib/tclconfig-shared.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "c:/Tcl/lib/tkconfig-shared.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. WARNING: found "c:/Tcl/lib/tclConfig.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "c:/Tcl/lib/tkConfig.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tclConfig-shared.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tkConfig-shared.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tclconfig-shared.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tkconfig-shared.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tclConfig.sh", but cannot find valid Tcl library for the tclConfig.sh. So, ignore it. WARNING: found "C:/Tcl/lib/tkConfig.sh", but cannot find valid Tk library for the tkConfig.sh. So, ignore it. To see why this extension failed to compile, please check the mkmf.log which can be found here: C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/tk-0.2.0/mkmf.log extconf failed, exit code 1
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問