0

Iam creating a Rails Applocation in Rails 3.2 in which I'm trying to implement twitter login using gem 'omniauth-twitter'. I have installed the same gem. Now I try to add my twitter credentials in /config/app.yml in Rails as:

config/app.yml

development: &default
 s3_bucket_name: xxxx
 aws_access_key_id: xxxx
 aws_secret_access_key: xxxx
 cloud_made_key: xxxx
 facebook_key: "xxxxx"
 facebook_secret: 'xxxxxxx'
 twitter_consumer_key: "xxxx"
 twitter_consumer_secret: "xxxxx"

When I restart my server I get the following error:

 error
/home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 8 column 0 (Psych::SyntaxError)
from /home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/psych.rb:106:in `load'
from /home/swati/projects/hackathon-io/config/application.rb:77:in `<class:Application>'
from /home/swati/projects/hackathon-io/config/application.rb:13:in `<module:HackathonIo>'
from /home/swati/projects/hackathon-io/config/application.rb:12:in `<top (required)>'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:53:in `require'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I searched for a solution and found the same problem and implemented the answer as specified in rails error, couldn't parse YAML.

/config/boot.rb

 require 'yaml'
 YAML::ENGINE.yamler = 'syck'

I restarted my server and again got the error:

`/home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 8, col 22: `   twitter_consumer_key: "xxxxx"' (ArgumentError)
from /home/swati/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/syck.rb:135:in `load'
from /home/swati/projects/hackathon-io/config/application.rb:77:in `<class:Application>'
from /home/swati/projects/hackathon-io/config/application.rb:13:in `<module:HackathonIo>'
from /home/swati/projects/hackathon-io/config/application.rb:12:in `<top (required)>'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-      3.2.6/lib/rails/commands.rb:53:in `require'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from /home/swati/.rvm/gems/ruby-1.9.2-p290@hackathon-io/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I am not able to figure out the syntax error. Please help me out to figure this error.

Community
  • 1
  • 1
Swati Aggarwal
  • 1,265
  • 3
  • 19
  • 34
  • Check your `app.yml` for tab characters (especially line 8). Yaml uses space characters for indentation, if you’ve got a tab character there you’ll see that error. – matt Oct 07 '12 at 20:36

2 Answers2

1

I faced the same issue and got it resolved by converting all tabs to spaces and removing extra spaces after script lets (if any in your code, I had few). Basically removed indentation in my yml file and it resolved issue and app started.

0

I was getting the same error with one of my yaml files and after seeing Matt's suggestion above regarding the tabs, I checked my editor (SublimeText) and switched to spaces instead of tabs for indentation and it resolved the issue.