我无法让红宝石成功地要求'tk'.我正在使用rvm,ruby 2.0.0,ActiveTcl-8.6和Ubuntu 12.04 LTS.我已经运行的愿望提供了ActiveTcl,它似乎是工作.
我查看了RVM站点http://rvm.io/integration/tk和几个StackOverflow问题,比如这个带有TK安装的RVM Ruby(OSX).
我试过rvm重新安装2.0.0 --enable-shared --enable-pthread --with-tk --with-tcl在不同版本的ruby上多次没有成功.
有什么想法吗?
当我运行irb并且确实需要'我得到以下内容:
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>'
Run Code Online (Sandbox Code Playgroud)
当这工作时,我认为你应该得到真实的回报.
我还没有尝试过其他任何事情,主要是因为我无法弄清楚还有什么可做的.我一直在研究如何工作并检查加载路径与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
Run Code Online (Sandbox Code Playgroud)
我认为这看起来像你期望的那样.对不起格式化,我是编辑的新手.
继续认为这是一个路径问题,我在我的文件中找到了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>'
Run Code Online (Sandbox Code Playgroud)
所以现在它需要 tk.rb文件中的'tcltklib'导致问题.这似乎证实了$ PATH或$ load_path存在一些问题.但搜索文件tcltklib.rb没有任何结果.有一个tcltklib.c文件.
我尝试了一些其他的东西.在通过rvm更仔细地读取ruby安装的输出之后,有一个关于X11 lib未安装的警告,并且在ruby构建之后Tk不会处于活动状态.我做了sudo apt-get install libx11-dev然后rvm再次重新安装2.0.0 --enable-shared --enable-pthread --with-tk --with-tcl.这次在irb中需要'tk'引起核心转储.我又试了一次,但它确实奏效了.然后我运行了一个短的ruby脚本,它也使用require'tk'.它也是核心倾销,但经过几次尝试后工作.现在它的成功与否,有时是有效的,有时是核心转储.
小智 6
不是sudo apt-get install tk就足够了,但你还需要安装下面的库文件,以便你的问题得到解决,你再也不会看到这个错误了.
$ sudo apt-get install libtcltk-ruby
谢谢KK
小智 3
我遇到了同样的情况。我尝试按如下方式跟踪它:
$cd ~/.rvm/src/ruby-2.1.1/ext/tk
$ruby extconf.rb
Run Code Online (Sandbox Code Playgroud)
进而:
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.
Run Code Online (Sandbox Code Playgroud)
看最后一行:“目前不支持Tcl/Tk8.6”。
解决:
$PATHrvm reinstall ruby-2.1.1 --with-tcl --with-tk| 归档时间: |
|
| 查看次数: |
7443 次 |
| 最近记录: |