我在这里遇到了一个非常奇怪的问题.
我在github上分叉了一个gem进行一些修改,在我的本地机器上克隆了我的repo,进行了更改并更改了另一个项目的Gemfile以从我的本地存储库中获取gem以进行测试.不幸的是,我在ruby脚本中需要gem时遇到LoadError.
rvm current => ruby-1.9.3-p448 ruby --version => ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux] bundle --version => Bundler version 1.3.5
我的Gemfile的内容:
source 'http://rubygems.org gem 'steps',:path => "/home/benny/workspace/steps"
捆绑输出:
$bundle --no-cache Resolving dependencies... Using colored (1.2) Using highline (1.6.19) Using steps (1.0.2) from source at /home/benny/workspaces/steps Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. $bundle show steps /home/benny/workspaces/steps
通过irb测试工作正常:
$bundle exec irb 1.9.3-p392 :001 > require 'rubygems' => false 1.9.3-p392 :002 > require 'steps' => true
通过脚本测试不起作用:
$cat test.rb require 'rubygems' require 'steps' $ruby test.rb /home/benny/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- steps (LoadError) from /home/benny/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from test.rb:2:in `<main>'
我现在很困惑.如果我使用:git而不是:使用本地git repo或github repo的路径,也会发生同样的情况.
有任何想法吗?
解决方法
在运行test.rb之前,您必须加载bundler环境
bundle exec ruby test.rb