问题
I installed the irbtools gem, but I can't require it.
$ sudo gem1.9.1 install irbtools
Successfully installed irbtools-0.8.7
1 gem installed
Installing ri documentation for irbtools-0.8.7...
Building YARD (yri) index for irbtools-0.8.7...
Installing RDoc documentation for irbtools-0.8.7...
$ gem1.9.1 which irbtools # yup, installed OK
/var/lib/gems/1.9.1/gems/irbtools-0.8.7/lib/irbtools.rb
$ ls /var/lib/gems/1.9.1/gems/irbtools-0.8.7/lib/
irbtools irbtools.rb
$ ruby1.9.1 -e 'require "irbtools"'
<internal:lib/rubygems/custom_require>:33:in `require': no such file to load -- irbtools (LoadError)
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from -e:1:in `<main>'
It doesn't work in irb1.9.1 either. All other gems in /var/lib/gems/1.9.1/gem
seem to be working fine. Now I'm kinda dumbstruck.
Can anyone please help me track down what's going on? I'm not necessarily looking for a solution, but just an idea what to do to debug the problem.
I'm on Debian Squeeze with
$ ruby1.9.1 --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [i486-linux]
回答1:
This error is quite strange... I haven't got a debian here, but a generic solution would be to use rvm or build ruby from source.
Hints for debugging the problem:
- Does requiering or loading /var/lib/gems/1.9.1/gems/irbtools-0.8.7/lib/irbtools.rb directly work?
- Do your ruby binary and your gem binary really refer to the same installation?
- Can irbtools be found with the Gem.source_index method?: Gem.source_index.gems.keys.grep /irbtools/
来源:https://stackoverflow.com/questions/5541059/ruby-require-irbtools-raises-loaderror