我无法获得红宝石要求'tk'成功。我使用的是rvm、ruby 2.0.0、ActiveTcl-8.6和Ubuntu12.04LTS。我已经运行了 have 与ActiveTcl一起提供的功能,它似乎正在工作。
我看过RVM站点http://rvm.io/integration/tk和几个类似于StackOverflow的RVM Ruby with TK installation (OSX)问题。
我已经尝试过rvm重新安装2.0.0 -启用-共享-启用-p线程-与-tk--与-tk-与-tcl在不同版本的红宝石,但没有成功。
有什么想法吗?
当我运行irb并执行要求‘’tk‘时,我得到以下信息:
LoadError: cannot load such file -- tk
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):2
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'当这起作用时,我认为您应该让真返回。
我没有试过别的,主要是因为我想不出还能做些什么。我一直在研究require是如何工作的,并使用ruby -e‘$检查加载路径:’
[brooks@ubuntu:~/sites/depot]$ruby -e 'puts $:'
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/x86_64-linux
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby/2.0.0
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby/2.0.0/x86_64-linux
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0
/home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/x86_64-linux我想这就像你所期望的那样。不好意思,我是新来的编辑。
根据这是路径问题的想法,我在我的文件中找到了tk.rb,并在irb中尝试了以下操作:
2.0.0-p353 :003 > require '/home/brooks/.rvm/src/ruby-2.0.0-p353/ext/tk/lib/tk'
LoadError: cannot load such file -- tcltklib
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/brooks/.rvm/src/ruby-2.0.0-p353/ext/tk/lib/tk.rb:6:in `<top (required)>'
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):3
from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'所以现在是要求tk.rb文件中的'tcltklib'造成了问题。这似乎证实了$PATH或$load_path存在一些问题。但是对tcltklib.rb文件的搜索什么也找不到。有一个tcltklib.c文件。
我又试了几样东西。在更仔细地阅读了通过rvm安装的ruby输出之后,有一个警告说没有安装X11库,并且在ruby构建之后Tk将不会活动。我做了sudo apt安装libx11 11-dev,然后rvm重新安装2.0.0 -启用-共享-启用-p线程-与-tk-与-tk-与-tcl再次。这一次在irb中,要求'tk'导致了一个内核转储。我又试了一次,成功了。然后,我运行了一个简短的红宝石脚本,它也使用require 'tk'。它的核心也被抛弃了,但经过几次尝试就成功了。现在这两者都被击中或错过,有时起作用,有时起核心作用。
发布于 2015-03-11 05:16:26
不是只需要安装tk就够了,但是你也需要安装下面的库文件,这样你的问题就可以解决了,你再也不会看到这个错误了。
$ sudo apt-get install libtcltk-ruby
谢谢KK
发布于 2014-04-28 12:10:09
我也遇到过同样的情况。我试着跟踪它,如下所示:
$cd ~/.rvm/src/ruby-2.1.1/ext/tk
$ruby extconf.rb然后:
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.看最后一行:“目前不支持Tcl/Tk8.6。”
解决以下问题:
$PATHrvm reinstall ruby-2.1.1 --with-tcl --with-tk发布于 2014-06-07 01:25:45
在MacOSX10.6.8上,将active-tcl降级到8.5版对我起了作用。
但这也行不通,所以请看这里:
rvm reinstall ruby-2.1.2 --with-tcl --with-tkhttps://stackoverflow.com/questions/20874900
复制相似问题