2

我正在使用 Capistrano 帮助部署 Rails 项目,当我运行命令时cap deploy,出现以下错误。有人知道出了什么问题吗?

这是尝试执行命令时生成的错误。

* executing "cd -- /var/www/crowdcode/releases/20130831210643 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"
 servers: ["54.215.187.53"]
 [54.215.187.53] executing command
*** [err :: 54.215.187.53] Faraday: you may want to install system_timer for reliable timeouts
*** [err :: 54.215.187.53]
*** [err :: 54.215.187.53] rake aborted!
*** [err :: 54.215.187.53] /var/www/crowdcode/releases/20130831210643/config/initializers/redis.rb:1: syntax error, unexpected ':', expecting ')'
*** [err :: 54.215.187.53] $redis = Redis.new(host: 'localhost', port: 6379, driver: :hiredis)
*** [err :: 54.215.187.53] ^
*** [err :: 54.215.187.53] /var/www/crowdcode/releases/20130831210643/config/initializers/redis.rb:1: syntax error, unexpected ',', expecting $end
*** [err :: 54.215.187.53] $redis = Redis.new(host: 'localhost', port: 6379, driver: :hiredis)
*** [err :: 54.215.187.53] ^
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/engine.rb:588
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `run_initializers'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `send'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
*** [err :: 54.215.187.53] /var/www/crowdcode/releases/20130831210643/config/environment.rb:5
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:184:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/actionpack-3.2.11/lib/sprockets/assets.rake:93
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:184:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:205:in `invoke_prerequisites'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:183:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/actionpack-3.2.11/lib/sprockets/assets.rake:60
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:184:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/actionpack-3.2.11/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:184:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:73:in `run'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
*** [err :: 54.215.187.53] /var/www/crowdcode/shared/bundle/ruby/1.8/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
*** [err :: 54.215.187.53] Tasks: TOP => environment
*** [err :: 54.215.187.53] (See full trace by running task with --trace)
command finished in 2472ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/crowdcode/releases/20130831210643; true"
    servers: ["54.215.187.53"]
    [54.215.187.53] executing command
    command finished in 21ms
failed: "sh -c 'cd -- /var/www/crowdcode/releases/20130831210643 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile'"

编辑:这是 redis.rb 中的内容

$redis = Redis.new(host: 'localhost', port: 6379, driver: :hiredis)
class << $redis

  def get_json_list(key)
    str = "[" <<  $redis.lrange(key, 0, -1).join(',') << "]"
    JSON.parse(str)
  end

end

编辑2:

问题是它以某种方式运行了错误的 Ruby 版本,从错误中我们可以看到它显示的是 1.8。所以我必须确保我的系统默认为 1.9.3,瞧!没有更多的语法错误,它能够正常运行。

4

2 回答 2

0

这是在黑暗中拍摄的。我还将验证您部署此应用程序的环境是否使用相同版本的 ruby​​ 和 rails。

当我部署我的最后一个应用程序时,我遇到了各种语法错误并且发疯了,直到我意识到我没有调整我的 rvm。

于 2013-09-01T02:55:57.877 回答
0

这不是法拉第的错误。这是您的初始化程序中的语法错误,因为此行表明:

*** [err :: 54.215.187.53] /var/www/crowdcode/releases/20130831210643/config/initializers/redis.rb:1: syntax error, unexpected ':', expecting ')'

您想检查config/initializers/redis.rb任何语法错误。

于 2013-08-31T22:09:45.110 回答