10
我需要從普通的ruby腳本引用本地gem,而不安裝gem。對How to refer a local gem in ruby?的蹤跡,我試着用以下設置創建的Gemfile:如何從ruby腳本引用本地gem?
%w(
custom_gem
another_custom_gem
).each do |dependency|
gem dependency, :path => File.expand_path("../../#{dependency}", __FILE__)
end
和腳本如下所示:
require 'custom_gem'
CustomGem::Do.something
當我執行此:
bundle exec ruby script.rb
我得到:
script.rb:1:in `require': cannot load such file -- custom_gem (LoadError) from script.rb:1:in `<main>'
如果我離開了require 'custom_gem'
,我得到:
script.rb:3:in `<main>': uninitialized constant CustomGem (NameError)
我甚至嘗試沒有捆綁,只是在腳本本身寫gem ... :path =>̣ ...
,但沒有結果。是否有任何其他方式從ruby腳本引用自定義gems,而無需在本地安裝gems?
是的,有拼寫錯誤,需要其他東西腳本中的寶石。謝謝! – tohokami