【问题标题】:deploying rails app with rubber to AWS - nil:NilClass error将带有橡胶的 Rails 应用程序部署到 AWS - nil:NilClass 错误
【发布时间】:2013-10-20 13:52:39
【问题描述】:

我第一次尝试使用 Rubber 部署到我的 AWS EC2。为了测试我现在只使用 t1.micro。

在 tcap Rubber:create_staging 之后编辑 Rubber.yml 后,我遇到了一个奇怪的橡胶错误

这是消息:

/Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:1:in `expand_string': undefined method `known_roles' for nil:NilClass (NoMethodError)
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:168:in `eval'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:168:in `expand_string'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:180:in `expand'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:146:in `[]'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/environment.rb:230:in `method_missing'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/rubber-2.5.5/lib/rubber/recipes/rubber/utils.rb:22:in `block (2 levels) in load'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/configuration/execution.rb:89:in `execute_task'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/execute.rb:45:in `each'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/execute.rb:34:in `execute!'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/lib/capistrano/cli/execute.rb:14:in `execute'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/gems/capistrano-2.15.5/bin/cap:4:in `<top (required)>'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/bin/cap:23:in `load'
    from /Users/mgreschke/Dropbox/medisupply/vendor/bundle/bin/cap:23:in `<main>'

知道在哪里查找错误吗?这对我来说似乎是一个简单的问题,但我真的不知道在哪里看..

最好, M

【问题讨论】:

  • 在您的整个应用程序中(可能在您的environment.rb)中查找关键字known_roles 调用此方法的对象返回为nil。如果您可以发布有关正在调用的对象的更多详细信息,它将对调试更有帮助。
  • 您已经解决了这个问题吗?发布解决方案会很有帮助。
  • Sergey,您在下面的帖子和链接帮助解决了问题。谢谢!

标签: ruby-on-rails amazon-web-services rubber


【解决方案1】:

只需删除 rubber_env。

staging_roles: "#{known_roles.reject {|r| r =~ /slave/ || r =~ /^db$/ }.join(',')}"
# instead of
staging_roles: "#{rubber_env.known_roles.reject {|r| r =~ /slave/ || r =~ /^db$/ }.join(',')}"

有这个简单的修复https://github.com/rubber/rubber/pull/406/files

【讨论】:

  • 谢谢谢尔盖。这解决了解决为complete_unicorn_nginx_postgresql 模板创建的应用程序的问题
猜你喜欢
  • 2013-01-17
  • 1970-01-01
  • 2012-09-13
  • 2014-11-11
  • 2016-06-04
  • 1970-01-01
  • 2013-03-18
  • 2016-03-18
  • 1970-01-01
相关资源
最近更新 更多