小编Joh*_*ary的帖子

在另一个项目中执行捆绑安装的 rake 任务

如何编写 rake 任务以在不同项目中运行捆绑安装?我用耙子创建了一个项目,并编写了这样的任务

task :bundle do
  projects.each do |name, repo|
    if Dir.exists?("../#{name}")
      exec("cd ../#{name} && bin/bundle install")
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我得到:

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.
Run Code Online (Sandbox Code Playgroud)

乍一看没问题,但实际上是bundle install针对当前的 rake-only 项目,而不是目标 Rails 项目。

我也试过回蜱

puts `cd ../#{name} && bin/bundle install`
Run Code Online (Sandbox Code Playgroud)

但它也做了同样的事情。我也试过 justbundle install而不是bin/bundle install,但没有奏效。

当我直接在命令上运行它时,它会按照我的预期运行:

Using rake 10.4.2
Using CFPropertyList 2.3.1
...
... …
Run Code Online (Sandbox Code Playgroud)

ruby bash rake bundle ruby-on-rails

2
推荐指数
1
解决办法
1491
查看次数

标签 统计

bash ×1

bundle ×1

rake ×1

ruby ×1

ruby-on-rails ×1