我有Ubuntu 9.04 Ruby 1.8 Rubygems 1.3.5
在irb,
irb(main):002:0> require 'rubygems'
=> true
在剧本中
$ ./test.rb
./test.rb:2:in `require': no such file to load -- rubygems (LoadError)
from ./test.rb:2
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.6 (2009-08-04 patchlevel 383) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
$ which ruby
/usr/local/bin/ruby
我认为它可能与我的PATH有关,但我不确定如何修复或修复什么。
我的$ LOAD_PATH变量似乎有gem目录的路径。
$ gem env gemdir
/usr/local/lib/ruby/gems/1.8
$ irb
irb(main):001:0> $LOAD_PATH
=> ["/usr/local/lib/ruby/site_ruby/1.8", "/usr/local/lib/ruby/site_ruby/1.8/i686-linux", "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/1.8", "/usr/local/lib/ruby/1.8/i686-linux", "."]
答案 0 :(得分:1)
检查$LOAD_PATH
,此变量包含使用require
时ruby查找的路径。
答案 1 :(得分:0)
我猜测irb中的shebang线指的是与$ PATH中的红宝石不同的红宝石。试试
$ ruby $(type -p irb)
看看你的'require'rubygems“是否仍然有效。如果没有,看看#!在irb中看到它正在使用的红宝石...