psych.rb中的Rails服务器错误:370

时间:2015-08-29 21:01:32

标签: ruby-on-rails

我在Mac上运行任何帮助都将不胜感激。 当我尝试启动我的Rails服务器时,我收到以下错误:

Richards-MBP:learn-rails richardxxxx$ rails server
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:370:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 13 column 1 (Psych::SyntaxError)
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:318:in `parse'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:245:in `load'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/application.rb:391:in `secrets'
    from /Users/richardxxxx/Ruby/learn-rails/config/environments/development.rb:32:in `block in <top (required)>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/railtie.rb:210:in `instance_eval'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/railtie.rb:210:in `configure'
    from /Users/richardxxxx/Ruby/learn-rails/config/environments/development.rb:1:in `<top (required)>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/engine.rb:597:in `each'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/engine.rb:597:in `block in <class:Engine>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `call'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /Users/richardxxxx/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
    from /Users/richardxxxx/Ruby/learn-rails/config/environment.rb:5:in `<top (required)>'
    from /Users/richardxxxx/Ruby/learn-rails/config.ru:3:in `require'
    from /Users/richardxxxx/Ruby/learn-rails/config.ru:3:in `block in <main>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /Users/richardxxxx/Ruby/learn-rails/config.ru:in `new'
    from /Users/richardxxxx/Ruby/learn-rails/config.ru:in `<main>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/server.rb:61:in `app'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/server.rb:139:in `log_to_stdout'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/server.rb:78:in `start'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in `block in server'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/richardxxxx/Ruby/learn-rails/bin/rails:8:in `require'
    from /Users/richardxxxx/Ruby/learn-rails/bin/rails:8:in `<top (required)>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `load'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `call'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/client/command.rb:7:in `call'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/client.rb:26:in `run'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/bin/spring:48:in `<top (required)>'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `load'
    from /Users/richardxxxx/.rvm/gems/ruby-2.2.1@learn/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `<top (required)>'
    from /Users/richardxxxx/Ruby/learn-rails/bin/spring:13:in `require'
    from /Users/richardxxxx/Ruby/learn-rails/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'
Richards-MBP:learn-rails richardxxxx$ 

Secrets.yml

发展:     secret_key_base:xxxxxxxxxxxxxxxxx7b55dd0770dd2e4944b27f9e142ce21489b4d345d867d6264bb4115322d3b062cdc208994280f16f3f144fffdb6f81dd452b66d44

email_provider_username: <%= ENV["xxxxxxx@gmail.com"] %> 
email_provider_password: <%= ENV["xxxxxxxxx"] %> 
mailchimp_api_key: <%= ENV["xxxxxxxxxxxxxxxx"] %>
mailchimp_list_id: <%= ENV["xxxxxxxxxx"] %> 
#domain_name: example.com 
owner_email: <%= ENV["xxxxxxxx@gmail.com"] %> 

试验:     secret_key_base:xxxxxxxxxxxxxxxx3c55f9391abd14598cf558fdf97f54257afe621beadc1932df61a00a3af47e56bc6d82b029439a429f9a1ce2a5e1d3a9654ac4bb7357

#不要在存储库中保留生产机密,  #而不是从环境中读取值。  制作:

email_provider_username: <%= ENV["GMAIL_USERNAME"] %> 
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %> 
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %> 
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %> 
#domain_name: <%= ENV["DOMAIN_NAME"] %> 
owner_email: <%= ENV["OWNER_EMAIL"] %> 
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

1 个答案:

答案 0 :(得分:6)

请检查secret.yml文件。这个错误几乎是yml文件缩进。

例(secret.yml)

development:
  secret_key_base: xxxxxxxxxxxxxxxxxxxx
staging:
  secret_key_base: xxxxxxxxxxxxxxxxxxxx
test:
  secret_key_base: xxxxxxxxxxxxxxxxxxxx
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
item:
 name: apple
  price: 10

日志

  Exiting
  /Users/haradaatsushi/.rbenv/versions/2.2.0/lib/ruby/2.2.0/psych.rb:370:in `parse': (<unknown>): mapping values are not allowed in this context at line 11 column 8 (Psych::SyntaxError)