Ruby on rails NoMethodError:未定义的方法“map';角色:Capistrano 3中的符号

Ruby on rails NoMethodError:未定义的方法“map';角色:Capistrano 3中的符号,ruby-on-rails,capistrano,capistrano3,Ruby On Rails,Capistrano,Capistrano3,我正在尝试将我的一些RubyonRails项目从Capistrano2.x升级到Capistrano3.x 我遵循这一伟大的原则来设置配置文件。我的配置文件如下所示: task :name, [:arg, :arg] => :dependency do ... end task :dump, :roles => :db do ... end Capfile require 'capistrano/setup' require 'capistrano/deploy' re

我正在尝试将我的一些RubyonRails项目从Capistrano2.x升级到Capistrano3.x

我遵循这一伟大的原则来设置配置文件。我的配置文件如下所示:

task :name, [:arg, :arg] => :dependency do
  ...
end
task :dump, :roles => :db do
  ...
end
Capfile

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rails'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
部署.rb

lock '3.4.0'

set :scm, :git
set :deploy_user, "deploy"
set :repo_url, "git_url"

set :application, "app_name"
set :local_app, "193/#{application}"
set :deploy_to, "/home/#{deploy_user}/rails/#{application}"

set :pty, true
set :ssh_options, {:forward_agent => true}

set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}


###
# BBDD settings
#

set :db_passwd, "db_password"
set :db_name, "db_name_production"
set :stage, :production
set :rails_env, :production

set :server_ip, "xxx.xxx.xxx.xxx"

server server_ip, user: 'deploy', roles: %w{web app db}

role :app, server_ip
role :web, server_ip
role :db,  server_ip, :primary => true
部署/生产.rb

lock '3.4.0'

set :scm, :git
set :deploy_user, "deploy"
set :repo_url, "git_url"

set :application, "app_name"
set :local_app, "193/#{application}"
set :deploy_to, "/home/#{deploy_user}/rails/#{application}"

set :pty, true
set :ssh_options, {:forward_agent => true}

set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}


###
# BBDD settings
#

set :db_passwd, "db_password"
set :db_name, "db_name_production"
set :stage, :production
set :rails_env, :production

set :server_ip, "xxx.xxx.xxx.xxx"

server server_ip, user: 'deploy', roles: %w{web app db}

role :app, server_ip
role :web, server_ip
role :db,  server_ip, :primary => true
现在,当我尝试显示我的Capistrano任务或尝试部署我的项目时,Capistrano抛出了一个错误

(回溯仅限于导入的任务)cap已中止!命名错误: 未定义的方法“映射”:角色:符号

(通过使用--trace运行任务查看完整跟踪)

我花了一天时间在谷歌上搜索,没有结果。有什么想法吗

编辑

cap生产部署:设置--跟踪

cap中止!
NoMethodError:未定义的方法“映射”:角色:符号
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task.rb:309:in'set\u arg\u names'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task_manager.rb:40:in“define_task”
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task.rb:365:在“定义任务”中
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/dsl_definition.rb:66:在“任务”中
/Users/carro/Sites/193/capistrano/lib/capistrano/tasks/deploy.rake:4:in'block-in'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task_manager.rb:209:in`in_名称空间'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/dsl_definition.rb:147:在“名称空间”中
/Users/carro/Sites/193/capistrano/lib/capistrano/tasks/deploy.rake:1:in`'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in'load'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in'load_rakefile'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/default_loader.rb:10:in'load'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:767:in'load_imports'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/capistrano-3.4.0/lib/capistrano/application.rb:93:in'load_imports'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:697:in'raw\u load\u rakefile'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:94:in'block in load_rakefile'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:176:在“标准异常处理”中
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:93:in'load_rakefile'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:77:在“运行中的块”中
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:176:在“标准异常处理”中
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:75:in'run'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in'run'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/capistrano-3.4.0/bin/cap:3:in`'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/cap:23:in'load'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/cap:23:in`'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/ruby\u executable\u hooks:15:in'eval'
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/ruby\u executable\u hooks:15:in`'

之所以会发生这种情况,是因为Capistrano任务现在是Rake任务,Rake需要这样的构造:

task :name, [:arg, :arg] => :dependency do
  ...
end
task :dump, :roles => :db do
  ...
end
从堆栈跟踪判断,您在
/Users/carro/Sites/193/Capistrano/lib/Capistrano/tasks/
中定义了自定义Capistrano任务。你需要把它们转换成Capistrano 3
,在。。。角色
语法使其工作

例如,您可以如下更改Capistrano 2任务:

task :name, [:arg, :arg] => :dependency do
  ...
end
task :dump, :roles => :db do
  ...
end
对于Capistrano 3:

task :dump do
  on primary roles :db do
    ...
  end
end

有关更多详细信息,请参阅。

Map是数组方法,在您调用的代码中的某个地方:roles,因此它抱怨该错误。不,它不是代码中的错误,或者至少不是我编写的方法映射。如果我在word map中执行“在项目中查找”操作,则没有结果。您是否可以运行
cap production deploy:setup--trace
以查看更多信息?