ruby-on-rails-4amazon-web-servicesnginxcapistranorvm-capistrano

SSHKit::Runner::ExecuteError: Exception while executing as deploy@xxxxx


I am trying to deploy my rails applications to AWS using NGINX and Capistrano. running the deploy command:

$ cap production deploy

[41abe7d2] Running ~/.rvm/bin/rvm version as deploy@172.31.20.41
DEBUG [41abe7d2] Command: ~/.rvm/bin/rvm version
DEBUG [41abe7d2]    rvm 1.26.11 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [41abe7d2]
DEBUG [41abe7d2] Finished in 0.429 seconds with exit status 0 (successful).
rvm 1.26.11 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [61defd93] Running ~/.rvm/bin/rvm current as deploy@172.31.20.41
DEBUG [61defd93] Command: ~/.rvm/bin/rvm current
DEBUG [61defd93]    ruby-2.2.1
DEBUG [61defd93]
DEBUG [61defd93] Finished in 0.140 seconds with exit status 0 (successful).
ruby-2.2.1
DEBUG [01260e54] Running ~/.rvm/bin/rvm ruby 2.2.1p85 do ruby --version as deploy@172.31.20.41
DEBUG [01260e54] Command: ~/.rvm/bin/rvm ruby 2.2.1p85 do ruby --version
DEBUG [01260e54]    Please note that `rvm ruby ...` was removed, try `ruby 2.2.1p85 do ruby --version` or `rvm all do ruby 2.2.1p85 do ruby --version` instead. ( see: 'rvm usage' )
DEBUG [01260e54]
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@172.31.20.41: ruby exit status: 1
ruby stdout: Please note that `rvm ruby ...` was removed, try `ruby 2.2.1p85 do ruby --version` or `rvm all do ruby 2.2.1p85 do ruby --version` instead. ( see: 'rvm usage' )
ruby stderr: Nothing written

here is my capfile

# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/rails/assets' # for asset handling add
require 'capistrano/rails/migrations' # for running migrations
require 'capistrano/puma'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

here is my deploy.rb

# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'Speyskraft_cms'
set :repo_url, 'https://onozor@bitbucket.org/onozor/speyskraft_cms.git' # Edit this to match your repository
set :branch, :master
set :deploy_to, '/home/deploy/speyskraft_cms'
set :scm_username, "deploy"
set :scm_passphrase, "onozorgheneho"
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby 2.2.1p85' # Edit this if you are using MRI Ruby

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

namespace :deploy do

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

please can some help me out of this mess this is my first time deploying on AWS. Thanks in Advance.


Solution

  • That is because of space in your :rvm_ruby_version causing deprecated-like rvm commands to be generated, try replacing to:

    set :rvm_ruby_version, 'ruby-2.2.1p85'