2013-08-12 13 views
6

Ho un problema davvero strano qui.LoadError richiedendo una gemma con: path o: git

Ho biforcato un gioiello su github per apportare alcune modifiche, clonato il mio repository sul mio computer locale, ho apportato le modifiche e modificato il Gemfile di un altro progetto per recuperare la gemma dal mio repository locale per testarlo. Sfortunatamente ottengo un LoadError mentre richiedo quella gemma nel mio script ruby.

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 

contenuto del mio Gemfile:

source 'http://rubygems.org 

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

uscita Bundle:

$ 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 

test tramite opere IRB bene:

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

test tramite script non funziona:

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

Sono molto confuso in questo momento. Lo stesso accade se uso: git al posto di: percorso con git repo locale o repo github.

Qualche idea?

risposta

12

Dovrete caricare l'ambiente bundler prima di eseguire l'test.rb

bundle exec ruby test.rb 
+1

Opere. Grazie! – phortx

+0

Wow Mi sono grattato la testa per l'ultima mezz'ora .... Gem installa multe, lo mostra in bundler ma non puoi caricarlo. Puoi per favore fornire una piccola spiegazione di PERCHÉ abbiamo bisogno di usare bundle exec per le gemme locali? – BlackDivine

0

È possibile eseguire con l'ambiente Bundler via: bundle exec ruby script.rb

o richiedere l'installazione bundler nello script prima della gemma (s) che stanno causando il problema. require 'bundler/setup'

La maggior parte dei collegamenti che ho trovato in merito a questa documentazione puntata sul sito di Bundler, ma sfortunatamente tutti i collegamenti sono purtroppo sfortunatamente.