Ruby require 'tk' yields LoadError: no such file to load — tk

旧城冷巷雨未停 提交于 2019-12-04 05:18:45

Not onty sudo apt-get install tk is enough but you also need the below library files to be installed so that your problem will be solved and you wont see this error never again.

$ sudo apt-get install libtcltk-ruby

thanks KK

JoeWoo

I met the same situation. I tried to track it like follows:

$cd ~/.rvm/src/ruby-2.1.1/ext/tk
$ruby extconf.rb

And then:

 check functions.checking for ruby_native_thread_p() in ruby.h... yes
.checking for rb_errinfo() in ruby.h... yes
.checking for rb_safe_level() in ruby.h... yes
.checking for rb_hash_lookup() in ruby.h... yes
.checking for rb_proc_new() in ruby.h... yes
.checking for rb_obj_untrust() in ruby.h... yes
.checking for rb_obj_taint() in ruby.h... yes
.checking for rb_set_safe_level_force() in ruby.h... yes
.checking for rb_sourcefile() in ruby.h... yes
.checking for rb_thread_alive_p() in ruby.h... no
.checking for rb_thread_check_trap_pending() in ruby.h... yes
.check struct members.checking for struct RArray.ptr in ruby.h... no
.checking for struct RArray.len in ruby.h... no
.check libraries.checking for t_open() in -lnsl... no
.checking for socket() in -lsocket... no
.checking for dlopen() in -ldl... yes
.checking for log() in -lm... yes
Use ActiveTcl libraries (if available).
Search tclConfig.sh and tkConfig.sh..
Ignore "/opt/ActiveTcl-8.6/lib/tclConfig-shared.sh" (unsupported version of Tcl/Tk).
Ignore "/opt/ActiveTcl-8.6/lib/tclConfig.sh" (unsupported version of Tcl/Tk).
..............................
Fail to find [tclConfig.sh, tkConfig.sh]
Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).
checking for XOpenDisplay() in -lX11... yes

Search tcl.h.checking for tcl.h... no
.Search tk.h.checking for tk.h... no
.Search Tcl library...............
Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled        on your Ruby. That is, Ruby/Tk will not work). Please check configure options.
Can't find proper Tcl/Tk libraries. So, can't make tcltklib.so which is required by Ruby/Tk.
If you have Tcl/Tk libraries on your environment, you may be able to use them with configure options (see ext/tk/README.tcltklib).
At present, Tcl/Tk8.6 is not supported. Although you can try to use Tcl/Tk8.6 with configure options, it will not work correctly. I recommend you to use Tcl/Tk8.5 or 8.4.

Look at the last line: "At present, Tcl/Tk8.6 is not supported."

To resolve:

  1. Uninstall active-tcl8.6.1
  2. Install 8.5 or 8.4 , add install path to $PATH
  3. rvm reinstall ruby-2.1.1 --with-tcl --with-tk
7stud

On Mac OSX 10.6.8, downgrading active-tcl to version 8.5 worked for me.

  1. Uninstall active-tcl8.6

    See: http://docs.activestate.com/activetcl/8.5/at.install.html

    After the directions there don't work, read the Note below the directions:

    Note: On Snow Leopard and higher the uninstall script is installed under /Library/Frameworks/Tcl.framework/Versions//Resources/Scripts/uninstall instead. Apple reorganized the directories for receipt storage and eliminated any space for 3rd-party files from it.

    But that won't work either, so see here:

    Uninstall Active TCL Mac

  2. Install active-tcl8.5

    See here: http://www.activestate.com/activetcl/downloads

    I didn't need to do anything to my $PATH.

  3. rvm reinstall ruby-2.1.2 --with-tcl --with-tk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!