Search code examples
ruby-on-railsrubycapistranocapistrano3

Capistrano/rails doesn't work with rvm


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

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:

bundle exec rails webpacker:install (instead of bundle 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:

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.

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?


Solution

  • You can use capistrano/bundler