[英]Error when running commands inside git submodule from Thor task
我有一個Rails 3.2項目,它是一個git repo,在vendor/autotest-new
目錄中,我有一個git子模塊。
我想使用雷神(Thor)自動執行某些操作。 例如,我需要在git子模塊中執行cucumber -d -f json > test.json
。
手動可以正常工作,但是當我運行thor任務時會拋出錯誤:
/home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': cucumber is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /home/user/.rvm/gems/ruby-2.0.0-p247@rails32/bin/cucumber:22:in `<main>'
from /home/user/.rvm/gems/ruby-2.0.0-p247@rails32/bin/ruby_noexec_wrapper:14:in `eval'
from /home/user/.rvm/gems/ruby-2.0.0-p247@rails32/bin/ruby_noexec_wrapper:14:in `<main>'
我已經在子模塊中運行了bundle install
。
我們的任務是:
class DB < Thor
include Thor::Actions
desc 'test_task', "test task"
def test_task
Dir.chdir("vendor/autotest-new") do
puts `bundle exec cucumber -d -f json > test.json`
end
end
end
我也嘗試過
run "bundle exec cucumber -d -f json > test.json"
system "bundle exec cucumber -d -f json > test.json"
但這沒有幫助。
不是雷神,它是捆扎機。
答案在這里https://github.com/bundler/bundler/issues/1579
我需要在塊中使用執行該命令
Bundler.with_clean_env do
#my commands
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.