Capistrano / rails不适用于rvm

时间:2022-06-24 12:52:33

I am trying to deploy Rails app with capistrano. It's Rails 5.1 based. Ruby version is managed by rvm. I am using ruby 2.2.3, created gemset manually. Here is deploy.rb

我正在尝试使用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

So, it seems worked when Rails < 5.0. But when Rails > 5.0, webpack should be installed by this command:

因此,当Rails <5.0时似乎有效。但是当Rails> 5.0时,应该通过以下命令安装webpack:

bundle exec rails webpacker:install (instead of bundle rake)

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

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

But it doesn't work for me. I've installed bundle in the gemset I am using, but getting error:

但它对我不起作用。我在我正在使用的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

Of course, I included capistrano/rails in my capfile.

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

capistrano/rvm
capistrano/rails

I am not sure why I am getting error. I think I configured correctly , but... Anyway, Would you like to help me to fix this issue?

我不知道为什么我会收到错误。我认为我配置正确,但是......无论如何,你想帮我解决这个问题吗?

1 个解决方案

#1


1  

You can use capistrano/bundler

你可以使用capistrano / bundler

#1


1  

You can use capistrano/bundler

你可以使用capistrano / bundler