2
votes

This is my first deploy - all steps I've made according to GoRails Tutorial: https://gorails.com/deploy/ubuntu/16.04

After "cap production deploy" command I receive that error message:

MacBook-Pro:app admin$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
Don't know how to build task 'deploy:setup' (see --tasks)

What's wrong?


Results for "cap production deploy --trace":

MacBook-Pro:app admin$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
Don't know how to build task 'deploy:setup' (see --tasks)
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task_manager.rb:71:in `[]'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:361:in `[]'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/dsl/task_enhancements.rb:7:in `before'
config/deploy.rb:27:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/setup.rb:27:in `load'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/setup.rb:27:in `block (3 levels) in <top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/configuration/variables.rb:32:in `untrusted!'
/Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/delegate.rb:83:in `method_missing'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/setup.rb:26:in `block (2 levels) in <top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/application.rb:14:in `run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/bin/cap:3:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/cap:23:in `load'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/cap:23:in `<main>'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => production

I've tried "cap deploy:check --trace":

MacBook-Pro:app admin$ cap deploy:check --trace
** Invoke ensure_stage (first_time)
** Execute ensure_stage
** Invoke deploy:check (first_time)
** Execute deploy:check
cap aborted!
Don't know how to build task ':check' (see --tasks)
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task_manager.rb:71:in `[]'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:361:in `[]'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/dsl.rb:15:in `invoke'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/tasks/deploy.rake:56:in `block (2 levels) in <top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/lib/capistrano/application.rb:14:in `run'
/Users/admin/.rvm/gems/ruby-2.3.1/gems/capistrano-3.6.1/bin/cap:3:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/cap:23:in `load'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/cap:23:in `<main>'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => deploy:check

config/deploy.rb (update capistrano 3.1 -> 3.6.1):

# config valid only for Capistrano 3.1
lock '3.6.1'

set :application, 'app'

set :rvm_type, :system

set :deploy_to, "/var/www/app/production"

set :deploy_via, :copy
set :use_sudo, false
set :repository, "/var/repos/app.git"
set :local_repository, "ssh://[email protected]/var/repos/app.git"
set :user, "deploy"
set :rails_env, "production"

before 'deploy:setup', 'rvm:install_rvm'

set :scm, :git

# Default value for :linked_files is []
set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}



namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  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

config/deploy/production.rb

role :app, %w{[email protected]}
role :web, %w{[email protected]}
role :db,  %w{[email protected]}

server '88.88.88.88', user: 'deploy', roles: %w{web app}, my_property: :my_value

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

set :stage, :production

# Includes default deployment tasks
require 'capistrano/deploy'


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

require 'capistrano/bundler'
require 'capistrano/rails'

# If you are using rbenv add these lines:
# require 'capistrano/rbenv'
# set :rbenv_type, :user     # or :system, depends on your rbenv setup
# set :rbenv_ruby, '2.0.0-p451'

# If you are using rvm add these lines:
require 'capistrano/rvm'

set :rvm_type, :user
set :rvm_ruby_version, '2.3.1-p112'

Gemfile

...
# CAPISTRANO gem
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
# Add this if you're using rvm
gem 'capistrano-rvm', github: "capistrano/rvm"
1

1 Answers

5
votes

That tutorial is horribly out of date. Here's what I would change (starting at the Capistrano Setup heading):

For both the rbenv and rvm gemfile entries, drop the github: 'something' part. The released Gem versions have been stable for a long time.

In the Capfile, they are correct that the require lines go in there, but the set lines should go in config/deploy.rb.

In config/deploy.rb, the restart section can be entirely replaced with the capistrano-passenger gem. That Gem's readme has instructions for installation. In general, it'll use passenger commands to perform the application restart, but you can also tell it to use the touch method which is identical to what the restart section is doing. You can also remove the after :finishing, 'deploy:cleanup' line.

In config/deploy/production.rb, you can remove set :stage, 'production'. You only need to set the stage if it is different from the filename.

Also, make sure you are running the latest versions of all the relevant gems by running bundle update gemname.