Синтаксическая ошибка Rails в файле YAML? - PullRequest
6 голосов
/ 10 августа 2011

Почему я получаю следующую ошибку при запуске rails console?

NOTE: Gem.available? is deprecated, use Specification::find_by_name. It will be removed on or after 2011-11-01.
Gem.available? called from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-1.0.2.1/lib/jasmine/base.rb:64.
syntax error on line 1, col 1: `:'
/Users/Chetan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:135:in `load'
/Users/Chetan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:135:in `load'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/instance_methods.rb:151:in `initialize'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:21:in `new'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:21:in `new_instance'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:8:in `instance'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `instance_exec'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `run'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:50:in `block in run_initializers'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `each'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `run_initializers'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/application.rb:92:in `initialize!'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/Chetan/Development/othermind/config/environment.rb:5:in `<top (required)>'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `block in require'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/application.rb:78:in `require_environment!'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/commands.rb:39:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
/Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/instance_methods.rb:156:in `rescue in initialize': Error reading newrelic.yml file: syntax error on line 1, col 1: `:' (RuntimeError)
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/instance_methods.rb:139:in `initialize'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:21:in `new'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:21:in `new_instance'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/new_relic/control/class_methods.rb:8:in `instance'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.1.1/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `instance_exec'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `run'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `each'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `run_initializers'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/application.rb:92:in `initialize!'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/Chetan/Development/othermind/config/environment.rb:5:in `<top (required)>'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `block in require'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/application.rb:78:in `require_environment!'
    from /Users/Chetan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc5/lib/rails/commands.rb:39:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Файл newrelic.yml, о котором идет речь (из кедрового раздела этого руководства ):

---
<%= ENV["RAILS_ENV"] %>:
  error_collector:
    capture_source: true
    enabled: true
    ignore_errors: ActionController::RoutingError
  apdex_t: 0.5
  ssl: false
  monitor_mode: true
  license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %>
  developer_mode: false
  app_name: <%= ENV["NEW_RELIC_APPNAME"] %>
  transaction_tracer:
    record_sql: obfuscated
    enabled: true
    stack_trace_threshold: 0.5
    transaction_threshold: apdex_f
  capture_params: false
  log_level: info

Хорошо разбирается с http://yaml -online-parser.appspot.com / ...

1 Ответ

12 голосов
/ 10 августа 2011

Ваше сообщение об ошибке указывает на то, что <%= ENV["RAILS_ENV"] %> появляется пустым, поэтому первая строка вашего YAML представляет собой просто двоеточие, и это не очень полезно.

Я предполагаю, что вы используете Rails 3, а ENV['RAILS_ENV'] больше не доступен (примечание: я знаю, что его нет в версии 3.1, но я не уверен насчет 3.0). Попробуйте использовать это:

<%= Rails.env %>:

Вместо этого Rails.env должно быть доступно в любых версиях Rails, которые вы, вероятно, будете использовать. И если это не сработает, попробуйте перейти прямо к:

production:

так как это, вероятно, в любом случае будет вашей средой Heroku.

...