我的Gemfile中有以下声明
gem'foo',: git => 'git@github.com:酒吧/ foo.git'
运行bundle install后,它可以检索以下文件夹下的gem
$ ls~/.rvm/gems/ruby-1.9.3-p0@samples/bundler/gems/foo-4dc3d7bf8271
但是在我的程序中使用需要'foo'并运行它的gem会引发以下问题。
custom_require.rb:36:在`require':无法加载这样的文件 - foo (LoadError)
如何解决此问题?
修改
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/i686-linu
x
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/vendor_ruby/1.9.1
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/vendor_ruby/1.9.1/i686-li
nux
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/vendor_ruby
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/i686-linux
/home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/
custom_require.rb:36:in `require': cannot load such file -- foo (LoadError)
from /home/ec2-user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.
9.1/rubygems/custom_require.rb:36:in `require'
答案 0 :(得分:0)
确保在require 'bundler/setup'
需要任何gem之前调用Gemfile
。但是在Rails案例中它确实应该发生,因为rails server
调用config/boot.rb
,其中包含这样的行。