0

我的 Gemfile 中有以下声明

gem 'foo', :git => 'git@github.com:bar/foo.git'

运行 bundle install 后,它可以在以下文件夹下检索 gem

$ ls ~/.rvm/gems/ruby-1.9.3-p0@samples/bundler/gems/foo-4dc3d7bf8271

但是在我的程序中使用 gem 并使用 require 'foo' 并运行它会引发以下问题。

custom_require.rb:36:in `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'
4

1 回答 1

0

确保require 'bundler/setup'在您需要Gemfile. 但在 Rails 的情况下,它肯定会发生,因为rails servercallsconfig/boot.rb包含这样的行。

于 2012-03-29T11:36:07.630 回答