使用Capistrano部署Rails,未定义的方法为nil

时间:2017-08-31 15:52:53

标签: ruby-on-rails ssh capistrano

首次将Rails应用程序部署到新服务器。

正在运行cap production deploy --trace给我:

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
NoMethodError: undefined method `upcase' for nil:NilClass
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/configuration.rb:90:in `logger'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/configuration.rb:51:in `output_verbosity='
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/configuration.rb:94:in `block in configure_backend'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit.rb:11:in `configure'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/configuration.rb:92:in `configure_backend'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/setup.rb:32:in `block (2 levels) in <top (required)>'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/application.rb:14:in `run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/bin/cap:3:in `<top (required)>'
/Users/dfaulken-af/.rbenv/versions/2.4.1/bin/cap:22:in `load'
/Users/dfaulken-af/.rbenv/versions/2.4.1/bin/cap:22:in `<main>'
Tasks: TOP => production

这似乎完全局限于宝石代码。在我向他们提出问题之前(sshkit?),有没有人见过这个?

我使用Net::SSH::Config从SSH配置文件中获取SSH用户。我知道这些设置是正确的,因为我可以使用它们登录服务器。

remote_user = Net::SSH::Config.for('50.198.83.200')[:user] || ENV['USER']
server '50.198.83.200', user: remote_user, roles: %w(app db web)

但我已尝试使用USER=the_user_name cap等设置远程用户,但仍然会收到相同的错误。

1 个答案:

答案 0 :(得分:0)

我的log_level行未完整写为

set :log_level

没有第二个论点。