RubyGems的。 新安装的gem不会添加到$ LOAD
我安装了新的稳定的Ruby版本,当我开始安装gems时,我发现在成功安装gem后,它们的路径不会添加到Ruby加载路径中。
这个问题的原因是什么? 我怎样才能实现它?
谢谢。
这是我的环境:
$ lsb_release -d
Description: Debian GNU/Linux 5.0.6 (lenny)
$ cat ~/.gemrc
gem: --no-ri --no-rdoc gemhome: /home/<username>/.gem gempath: - /home/<username>/.gem
$ gem environment
RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux] - INSTALLATION DIRECTORY: /home/<username>/.gem - RUBY EXECUTABLE: /usr/local/bin/ruby - EXECUTABLE DIRECTORY: /home/<username>/.gem/bin - RUBYGEMS PLATFORMS: - ruby - x86-linux - GEM PATHS: - /home/<username>/.gem - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - "gem" => "--no-ri --no-rdoc" - "gemhome" => "/home/<username>/.gem" - "gempath" => ["/home/<username>/.gem"] - REMOTE SOURCES: - http://rubygems.org/
$ gem list
*** LOCAL GEMS *** rack (1.2.1) sqlite3-ruby (1.3.1)
$ ruby -e "puts $:"
# There's neither /home/<username>/.gem/gems/rack-1.2.1/lib # nor home/<username>/.gem/gems/sqlite3-ruby-1.3.1/lib here. /usr/local/lib/ruby/site_ruby/1.9.1 /usr/local/lib/ruby/site_ruby/1.9.1/i686-linux /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/vendor_ruby/1.9.1 /usr/local/lib/ruby/vendor_ruby/1.9.1/i686-linux /usr/local/lib/ruby/vendor_ruby /usr/local/lib/ruby/1.9.1 /usr/local/lib/ruby/1.9.1/i686-linux
更新
我不能要求任何已安装的宝石,因为它们不在$:中。
$ ruby -e "require 'rack'; puts $:"
:29:in `require': no such file to load -- rack (LoadError) from :29:in `require' from -e:1:in `'
但。
$ ruby -e "$: << '/home/<username>/.gem/gems/rack-1.2.1/lib'; require 'rack'; puts $:"
/usr/local/lib/ruby/site_ruby/1.9.1 /usr/local/lib/ruby/site_ruby/1.9.1/i686-linux /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/vendor_ruby/1.9.1 /usr/local/lib/ruby/vendor_ruby/1.9.1/i686-linux /usr/local/lib/ruby/vendor_ruby /usr/local/lib/ruby/1.9.1 /usr/local/lib/ruby/1.9.1/i686-linux /home/<username>/.gem/gems/rack-1.2.1/lib # Here it is!
它只适用于这种方式:(
您尚未加载任何宝石:
ruby -e '
puts "Before require: #{$:.grep /rack/}"
require "rack"
puts "After require: #{$:.grep /rack/}"
'
# Before require: []
# After require: ["C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/bin",
# "C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib"]
ruby -e '
puts "Before gem: #{$:.grep /rack/}"
gem "rack"
puts "After gem: #{$:.grep /rack/}"
require "rack"
puts "After require: #{$:.grep /rack/}"
'
# Before gem: []
# After gem: ["C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/bin",
# "C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib"]
# After require: ["C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/bin",
# "C:/Ruby/YARV/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib"]
事情已经改变为1.9.2
http://wiki.github.com/rdp/ruby_tutorials_core/ruby-talk-faq#gem_loading_fails_191
它现在基本上会自动加载rubygems,而不是预先填充加载路径。
链接地址: http://www.djcxy.com/p/25269.html上一篇: Rubygems. A newly installed gem isn't added to $LOAD
下一篇: How can i execute 2 or more commands in the same ssh session?