如何在capistrano部署期间调试Psych :: SyntaxError?

时间:2013-10-23 10:10:05

标签: ruby-on-rails ruby capistrano bundler

我的数据库推送停止了工作。

这是我的deploy.rb文件:https://gist.github.com/a20d10a8a25c64c2d238

我正在使用'capistrano-db-tasks'。如何调试问题在哪里?

Are you sure you want to erase your local database with server database (y)es, (n)o  ? y
local {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"app-development", "username"=>"root", "password"=>nil, "host"=>"localhost", "port"=>3306}
  * executing "cat /home/app/current/config/database.yml"
    servers: ["213.238.59.107"]
    [213.238.59.107] executing command
    command finished in 345ms
/Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 1 column 14 (Psych::SyntaxError)
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:64:in `initialize'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:122:in `new'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:122:in `remote_to_local'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/dbtasks.rb:31:in `block (4 levels) in <top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/dbtasks.rb:38:in `block (3 levels) in <top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `each'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:34:in `execute!'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:14:in `execute'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/bin/cap:4:in `<top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/bin/cap:23:in `load'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/bin/cap:23:in `<main>'

1 个答案:

答案 0 :(得分:0)

问题在于你正在使用的capistrano-db-tasks宝石。

显然,它读取的配置文件,YAML文件,显然是格式错误。

Psych是Ruby附带的YAML解析器(https://github.com/tenderlove/psych),无法读取您的文件。

这本身不是卡皮斯特拉诺问题。

/home/app/current/config/database.yml服务器上的文件可能无法读取。您可以尝试通过YAML Lint(http://yamllint.com/)运行该文件以检查错误。

最近(在过去两年内,大约1.9时间变得越来越流行)Ruby(又名YARV,CRuby,MRI)从Ruby 2.0 YAML page切换了它的YAML解析器:

  

Syck¶↑

     

Syck是Ruby标准库中YAML实现的原创,为什么幸运的是僵硬。

     

如果您愿意,您仍然可以通过更改YAML::ENGINE来使用Syck:

     

YAML::ENGINE.yamler = 'syck'   # switch back to the default Psych   YAML::ENGINE.yamler = 'psych'

我确保你可以在你的(失败的)部署目录中的rails控制台上读取该文件,并且还联系capistrano-db-tasks gem的供应商,完全有可能它在其他一些YAML文件上失败了。