部署失败并出现错误:#<nomethoderror:undefined =“”method =“”`on'=“”for =“”main:object =“”>

时间:2016-03-23 02:04:32

标签: ruby-on-rails web-deployment digital-ocean

我将把rails app部署到数字海洋 我按照这个https://gorails.com/deploy/ubuntu/14.04的教程进行了练习 然后我在本地命令提示符下运行命令以进行部署。

# cap production deploy

运行命令后,出现以下错误。

 /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/i18n.rb:4: warning: duplicated key at line 6 ignored: :starting
    ** Invoke production (first_time)
    ** Execute production
    ** Invoke load:defaults (first_time)
    ** Execute load:defaults
    ** Invoke bundler:map_bins (first_time)
    ** Execute bundler:map_bins
    ** Invoke deploy:set_rails_env (first_time)
    ** Execute deploy:set_rails_env
    ** Invoke deploy:set_linked_dirs (first_time)
    ** Execute deploy:set_linked_dirs
    ** Invoke deploy:set_rails_env 
    ** Invoke deploy (first_time)
    ** Execute deploy
    ** Invoke deploy:starting (first_time)
    ** Execute deploy:starting
    ** Invoke deploy:check (first_time)
    ** Execute deploy:check
    ** Invoke git:check (first_time)
    ** Invoke git:wrapper (first_time)
    ** Execute git:wrapper
    cap aborted!
    NoMethodError: undefined method `on' for main:Object
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/git.rake:16:in `block (2 levels) in <top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `call'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `block in execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:209:in `block in invoke_prerequisites'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:207:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:207:in `invoke_prerequisites'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:186:in `block in invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/dsl.rb:14:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/deploy.rake:34:in `block (2 levels) in <top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `call'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `block in execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/dsl.rb:14:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/deploy.rake:4:in `block (2 levels) in <top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `call'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `block in execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/dsl.rb:14:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:65:in `block (2 levels) in <top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:64:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:64:in `block in <top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `call'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:248:in `block in execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:150:in `invoke_task'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:106:in `each'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:106:in `block in top_level'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:115:in `run_with_threads'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:100:in `top_level'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:78:in `block in run'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:176:in `standard_exception_handling'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-11.1.1/lib/rake/application.rb:75:in `run'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
    /Users/llvc/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
    /Users/llvc/.rbenv/versions/2.2.3/bin/cap:23:in `load'
    /Users/llvc/.rbenv/versions/2.2.3/bin/cap:23:in `<main>'
    Tasks: TOP => git:check => git:wrapper
    The deploy has failed with an error: #<NoMethodError: undefined method `on' for main:Object>
    ** Invoke deploy:failed (first_time)
    ** Execute deploy:failed

我从stackoverflow中发现了类似的问题。NoMethodError: undefined method `on' for main:Object
但解决方案无法帮助我。 我需要专家的额外帮助。 谢谢。金

2 个答案:

答案 0 :(得分:5)

变化:

gem 'capistrano', '~> 3.1.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'

为:

gem 'capistrano',            '~>3.5.0'
gem 'capistrano-bundler',   '~> 1.1.3'
gem 'capistrano-rails',     '~> 1.1.7'

如果在/config/deploy.rb中有:

lock '3.1.0'

更改为:

lock '3.5.0'

并运行:

bundle update

bundle install

答案 1 :(得分:2)

按照步骤后我可以解决这个问题 1 ..确保你正确地遵循了教程 2 ..删除Gemfile中的capestrano相关版本