2015-05-04 24 views
6

Próbuję uaktualnić niektóre z moich projektów Ruby on Rails z Capistrano 2.x do Capistrano 3.x.NoMethodError: niezdefiniowana metoda `map 'dla: ról: Symbol w Capistrano 3

Śledziłem to wspaniałe tutorial, aby skonfigurować pliki konfiguracyjne. Moje pliki konfiguracyjne wygląda następująco:

Capfile

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

require 'capistrano/rails' 

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

deploy.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" 

deploy/production.rb

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 

Teraz, kiedy próbuję pokazać moje zadania Capistrano lub kiedy próbuję wdrożyć mój projekt, Capistrano rzuca mi błąd.

(Backtrace restricted to imported tasks) cap aborted! NoMethodError: undefined method `map' for :roles:Symbol

(See full trace by running task with --trace)

enter image description here

ja spędziliśmy jeden dzień Googling bez rezultatów. Dowolny pomysł?

EDIT

cap deploy produkcja: setup --trace

cap aborted! 
NoMethodError: undefined method `map' for :roles:Symbol 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task.rb:309:in `set_arg_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:in `define_task' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/dsl_definition.rb:66:in `task' 
/Users/carro/Sites/193/capistrano/lib/capistrano/tasks/deploy.rake:4:in `block in <top (required)>' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/task_manager.rb:209:in `in_namespace' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/dsl_definition.rb:147:in `namespace' 
/Users/carro/Sites/193/capistrano/lib/capistrano/tasks/deploy.rake:1:in `<top (required)>' 
/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_load_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:in `standard_exception_handling' 
/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:in `block in run' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling' 
/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 `<top (required)>' 
/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 `<main>' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:in `eval' 
/Users/carro/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:in `<main>' 
+0

Mapa jest metodą tablicową, gdzieś w kodzie, do którego dzwonisz: role, więc narzeka na ten błąd. – uday

+0

Nie, to nie jest błąd w kodzie, a przynajmniej nie to, że napisałem mapę metody. Jeśli zrobię "Znajdź w projekcie" mapę słów, nie będzie żadnych wyników. –

+0

Czy możesz uruchomić 'cap production deploy: setup --trace', aby zobaczyć więcej informacji? – davids

Odpowiedz

14

Dzieje się tak dlatego, że zadania są teraz Capistrano zadania Rake Rake i oczekuje konstruktem tak:

task :name, [:arg, :arg] => :dependency do 
    ... 
end 

Sądząc po ślad stosu, masz niestandardowe zadania Capistrano określone w /Users/carro/Sites/193/capistrano/lib/capistrano/tasks/. Konieczne jest przekonwertowanie ich na składnię Capistrano 3 on ... roles, aby działały.

Na przykład, chcesz zmienić Capistrano 2 zadania tak:

task :dump, :roles => :db do 
    ... 
end 

do tego dla Kapistrana 3:

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

Zobacz here więcej szczegółów.