Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails syntax error in YAML file?

Why am I getting the following error when I run 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>'

The newrelic.yml file in question (from the Cedar section of this guide):

---
<%= 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

It parses fine with http://yaml-online-parser.appspot.com/...

like image 473
Chetan Avatar asked Aug 10 '11 06:08

Chetan


1 Answers

Your error message indicates that <%= ENV["RAILS_ENV"] %> is coming up empty so the first line of your YAML is just a single colon and that's not very useful.

I'd guess that you're using Rails 3 and ENV['RAILS_ENV'] is no longer available (note: I know it isn't around in 3.1 but I'm not certain about 3.0). Try using this:

<%= Rails.env %>:

instead, Rails.env should be available in any Rails versions that you're likely to be using. And if that doesn't work, you can try going straight to:

production:

since that will probably be your Heroku environment anyway.

like image 155
mu is too short Avatar answered Sep 20 '22 13:09

mu is too short