【发布时间】:2015-06-30 20:01:22
【问题描述】:
如何编写 rake 任务以在不同的项目中运行捆绑安装?我已经创建了一个只有 rake 的项目,并编写了这样的任务
task :bundle do
projects.each do |name, repo|
if Dir.exists?("../#{name}")
exec("cd ../#{name} && bin/bundle install")
end
end
end
但是当我运行它时,我得到:
Using rake 10.3.2
Using bundler 1.9.6
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
起初看起来不错,但实际上是当前仅 rake 项目而不是目标 rails 项目的bundle install。
我也尝试了反勾号
puts `cd ../#{name} && bin/bundle install`
但它也做了同样的事情。我也尝试了 bundle install 而不是 bin/bundle install,但没有成功。
当我直接在命令上运行它时,它会达到我的预期:
Using rake 10.4.2
Using CFPropertyList 2.3.1
...
...
Using turbolinks 2.5.3
Using uglifier 2.7.1
Bundle complete! 34 Gemfile dependencies, 120 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
如何让它正确处理bundle install?
【问题讨论】:
标签: ruby-on-rails ruby bash rake bundle