gpt4 book ai didi

ruby-on-rails - Rails 5 部署到 VPS - capistrano 错误 "Don' 不知道如何构建任务 'deploy:setup' "

转载 作者:行者123 更新时间:2023-12-02 20:59:17 24 4
gpt4 key购买 nike

这是我的第一次部署 - 我根据 GoRails 教程完成的所有步骤:https://gorails.com/deploy/ubuntu/16.04

在“cap生产部署”命令之后,我收到该错误消息:

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)

出了什么问题?


“cap生产部署--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

我尝试过“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(更新 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://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81e5e4f1edeef8c1b9b9afb9b9afb9b9afb9b9" rel="noreferrer noopener nofollow">[email protected]</a>/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

配置/部署/生产.rb

role :app, %w{<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="74101104181b0d344c4c5a4c4c5a4c4c5a4c4c" rel="noreferrer noopener nofollow">[email protected]</a>}
role :web, %w{<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44202134282b3d047c7c6a7c7c6a7c7c6a7c7c" rel="noreferrer noopener nofollow">[email protected]</a>}
role :db, %w{<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85e1e0f5e9eafcc5bdbdabbdbdabbdbdabbdbd" rel="noreferrer noopener nofollow">[email protected]</a>}

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

Cap文件

# 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'

gem 文件

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

最佳答案

那个教程已经过时了。以下是我要更改的内容(从 Capistrano 设置标题开始):

对于 rbenv 和 rvm gemfile 条目,删除 github: 'something'部分。已发布的 Gem 版本长期稳定。

在 Capfile 中,require 是正确的那里有几行,但是 set行应位于 config/deploy.rb .

config/deploy.rb ,重启部分可以完全替换为 capistrano-passenger gem 。 Gem 的自述文件包含安装说明。一般来说,它将使用乘客命令来执行应用程序重新启动,但您也可以告诉它使用与重新启动部分所做的相同的触摸方法。您还可以删除 after :finishing, 'deploy:cleanup'线。

config/deploy/production.rb ,您可以删除 set :stage, 'production' 。仅当舞台与文件名不同时才需要设置舞台。

此外,请通过运行 bundle update gemname 来确保您正在运行所有相关 gem 的最新版本。 .

关于ruby-on-rails - Rails 5 部署到 VPS - capistrano 错误 "Don' 不知道如何构建任务 'deploy:setup' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39151587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com