[英]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.