Capistrano/rails 不适用于 rvm

Capistrano/rails doesn't work with rvm

我正在尝试使用 capistrano 部署 Rails 应用程序。它基于 Rails 5.1。 Ruby 版本由 rvm 管理。 我正在使用 ruby 2.2.3,手动创建 gemset。 这里是deploy.rb

set :rvm_type, :user
set :rvm_ruby_version, '2.2.3@cardlove-api'
...
with RAILS_ENV: fetch(:environment) do
  execute :rake, "webpacker:install"
end

所以,当 Rails < 5.0 时似乎有效。但是当Rails > 5.0时,webpack应该通过这个命令来安装:

bundle exec rails webpacker:install (而不是捆绑耙)

with RAILS_ENV: fetch(:environment) do
  execute :rails, "webpacker:install"
end

但这对我不起作用。我已经在我正在使用的 gemset 中安装了 bundle,但出现错误:

01 bundle exec rails webpacker:install
01 bash: bundle: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@IP: rails 
  exit status: 127
  rails stdout: Nothing written
  rails stderr: bash: bundle: command not found

当然,我在我的 capfile 中包含了 capistrano/rails。

capistrano/rvm
capistrano/rails

我不确定为什么会出现错误。我认为我配置正确,但是...... 不管怎样,你愿意帮我解决这个问题吗?

您可以使用capistrano/bundler