LoadError 需要一个带有 :path 或 :git 的 gem [英] LoadError by requiring a gem with :path or :git

查看:26
本文介绍了LoadError 需要一个带有 :path 或 :git 的 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I've got a really strange problem here.

I forked a gem on github to do some modifications, cloned my repo on my local machine, made the changes and changed the Gemfile of another project to fetch the gem from my local repository for testing it. Unfortunately I get a LoadError while requiring that gem in my ruby script.

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

Content of my Gemfile:

source 'http://rubygems.org

gem 'steps', :path => "/home/benny/workspace/steps"

Bundle output:

$ 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

Testing via irb works fine:

$ bundle exec irb
1.9.3-p392 :001 > require 'rubygems'
 => false 
1.9.3-p392 :002 > require 'steps'
 => true

Testing via script doesn't work:

$ 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>'

I'm very confused right now. Same happens if I use :git instead of :path with local git repo or the github repo.

Any ideas?

解决方案

You'll have to load the bundler environment before running the test.rb

bundle exec ruby test.rb

这篇关于LoadError 需要一个带有 :path 或 :git 的 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆