Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 yaml errors

I am currently upgrading my application from rails 2.3 to 3.0 and ruby 1.9.3. After making the required changes and trying to access the home page of my app i'm getting the following error.

Psych::SyntaxError ((/apps/myapp/config/locales/en.yml): did not find expected node     content while parsing a flow node at line 73 column 14):
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:203:in `parse'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:151:in `parse'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:127:in `load'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:297:in `block in load_file'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:297:in `open'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych.rb:297:in `load_file'

The full stack trace can be found at : http://pastie.org/5478123

Line no 73 of en.yml contains

order: [:year, :month, :day]

Can someone help me in fixing this. Currently myapp is running on Rails 2.3.14 and ruby 1.8.7

like image 482
Sivakumar Avatar asked Dec 04 '12 10:12

Sivakumar


1 Answers

Ruby 1.9.3 uses Psych as its Yaml parser, and 1.8.7 used the older and obsolete Syck. The issue you’re seeing is a known issue in LibYaml, the library that Psych is built on, and is due to some ambiguity that arises when colons are allowed in flow context.

There’s a Ruby bug about this.

The solution is to change your Yaml to use the block context:

order: 
  - :year
  - :month
  - :day

Rails has changed the template that generated this Yaml to avoid this bug.

like image 136
matt Avatar answered Oct 21 '22 09:10

matt