I'm running into an SSHKit::Runner::ExecuteError while trying to push a ruby app from a repo to a remote server.
On
$: bundle exec cap production deploy
I get
DEBUG [506a96fd] Running [ -d ~/.rvm ] as deploy@168.257.12.345
DEBUG [506a96fd] Command: [ -d ~/.rvm ]
DEBUG [506a96fd] Finished in 1.496 seconds with exit status 1 (failed).
DEBUG [8e553e85] Running [ -d /usr/local/rvm ] as deploy@168.257.12.345
DEBUG [8e553e85] Command: [ -d /usr/local/rvm ]
DEBUG [8e553e85] Finished in 0.074 seconds with exit status 1 (failed).
DEBUG [d6f82812] Running ~/.rvm/bin/rvm version as deploy@168.257.12.345
DEBUG [d6f82812] Command: ~/.rvm/bin/rvm version
DEBUG [d6f82812] bash: /home/deploy/.rvm/bin/rvm: No such file or directory
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@168.257.12.345: rvm exit status: 127
rvm stdout: Nothing written
rvm stderr: bash: /home/deploy/.rvm/bin/rvm: No such file or directory
SSHKit::Command::Failed: rvm exit status: 127
rvm stdout: Nothing written
rvm stderr: bash: /home/deploy/.rvm/bin/rvm: No such file or directory
After many hours troubleshooting and searching similar error messages on the interweb I came to the question of whether it's common practice to install ruby on my local machine with rvm, and push an app from a repo to a remote machine where ruby is installed with rbenv. My thought was that the "No such file or directory" error meant that my local installation, based on how its installed locally, is looking for an rvm folder on the remote, and when it doesn't find it it complains.
My next step was to install the same ruby version locally, using rbenv, but other research supports that rvm is incompatible with rbenv and you should remove all traces of rvm before using rbenv. Both are installed on my local machine.
Is there a hack to make this work without having to do a blanket uninstall of rvm locally and every gem that's associated with it, or do I manually create the folder on the remote as explained in this answer? Honestly looking for the cleanest, best practice with this. Many thanks in advance.
Gemfile
# Added per gorails.com tutuorial @ gorails.com/deploy/ubunt/14.04
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'
# Add this if you're using rbenv
# gem 'capistrano-rbenv', github: "capistrano/rbenv"
gem 'capistrano-rvm', github: "capistrano/rvm"
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rvm'
set :rvm_type, :user
set :rvm_ruby_version, '2.0.0-p451'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
config/deploy.rb
lock '3.4.1'
set :application, 'my_app'
set :repo_url, 'https://github.com/my_acct/my_app.git'
set :deploy_to, '/home/deploy/#{my_app}'
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
end
config/deploy/production.rb
set :stage, :production
server '168.257.12.345', user: 'deploy', roles: %w{web app}
versions
ruby 2.3.1 (local and remote)
rbenv version 2.1.5
rvm 1.27.0