[英]Rails 5 deploy to VPS - capistrano error “Don't know how to build task 'deploy:setup' ”
This is my first deploy - all steps I've made according to GoRails Tutorial: https://gorails.com/deploy/ubuntu/16.04 这是我的第一个部署-根据GoRails教程执行的所有步骤: 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": “上限生产部署--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": 我已经尝试过“ 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 / deploy.rb(更新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://deploy@88.88.88.88/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 配置/部署/ production.rb
role :app, %w{deploy@88.88.88.88}
role :web, %w{deploy@88.88.88.88}
role :db, %w{deploy@88.88.88.88}
server '88.88.88.88', user: 'deploy', roles: %w{web app}, my_property: :my_value
Capfile 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 的Gemfile
...
# CAPISTRANO gem
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
# Add this if you're using rvm
gem 'capistrano-rvm', github: "capistrano/rvm"
That tutorial is horribly out of date. 该教程太过时了。 Here's what I would change (starting at the Capistrano Setup heading):
这就是我要更改的内容(从Capistrano设置标题开始):
For both the rbenv and rvm gemfile entries, drop the github: 'something'
part. 对于rbenv和rvm gemfile条目,都删除
github: 'something'
部分。 The released Gem versions have been stable for a long time. 发行的Gem版本已经稳定了很长时间。
In the Capfile, they are correct that the require
lines go in there, but the set
lines should go in config/deploy.rb
. 在Capfile中,正确的是将
require
行插入其中,但是set
行应放在config/deploy.rb
。
In config/deploy.rb
, the restart section can be entirely replaced with the capistrano-passenger gem . 在
config/deploy.rb
,重新启动部分可以完全替换为capistrano-passenger gem 。 That Gem's readme has instructions for installation. 该Gem的自述文件包含安装说明。 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.
通常,它将使用乘客命令来执行应用程序重新启动,但是您也可以告诉它使用与重新启动部分所执行的操作相同的touch方法。 You can also remove the
after :finishing, 'deploy:cleanup'
line. 您也可以删除
after :finishing, 'deploy:cleanup'
行。
In config/deploy/production.rb
, you can remove set :stage, 'production'
. 在
config/deploy/production.rb
,您可以删除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
. 另外,通过运行
bundle update gemname
,确保您正在运行所有相关gem的最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.