Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<Psych::SyntaxError: did not find expected key while parsing a block mapping

When I start the server, I get this error:

I18n::InvalidLocaleData
can not load translations from /Users/Apple/myapp-website-freelance/config/locales/fr.yml: #<Psych::SyntaxError: (/Users/Apple/myapp-website-freelance/config/locales/fr.yml): did not find expected key while parsing a block mapping at line 2 column 3>

Although, the yaml file seems normal at line 2 column 3:

fr:
  Electronics_Circuits_Simulator_Realistic_Interface: "Simulateur de circuits electroniques. Interface reelle."

Any idea?

like image 219
simo Avatar asked Jun 05 '17 15:06

simo


2 Answers

This error is often misleading and points the wrong line out

Look for extra spaces in the entire YML file and try to replace all enclosing single quotes by "", it should work !

One possible reason is:

default: &default
  a: 1
production: *default
  b: 2

in place of:

default: &default
  a: 1
production:
  <<: *default
  b: 2
like image 193
dimitri Avatar answered Sep 21 '22 13:09

dimitri


Check for any extra whitespace in your YML file. Also, if you were like me you might forgot to remove {} in YML template.

# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
like image 33
Ken Ratanachai S. Avatar answered Sep 23 '22 13:09

Ken Ratanachai S.