我正在处理我的第一个本地gem,由于某些原因,在尝试从IRB require
时出现错误。
我正在使用Ruby 1.9.3-p125并通过RVM安装它。
我在我的gem的父文件夹中运行它。结构是这样的:
| myGEM/
| myGEM.gemspec
| myGEM-0.0.1.gem
| lib/
| myGEM.rb
正如您所看到的,我运行了gem build myGEM.gemspec
来获取.gem
文件,并成功运行。
但是,我仍然无法从IRB(myGem
目录)中加载它。这是我的错误日志:
$ irb
1.9.3-p125 :001 > require 'myGEM'
LoadError: cannot load such file -- myGEM
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
我也尝试过首先要求rubygems,但这根本没有帮助。
1.9.3-p125 :002 > require 'rubygems'
=> false
1.9.3-p125 :003 > require 'myGEM'
LoadError: cannot load such file -- myGEM
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):3
from /Users/cnnr/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'