English 中文(简体)
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/...

最佳回答

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.

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签