Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml_db 0.2.1 incompatible with YAML engine 'psych' #18

Open
gamov opened this issue May 3, 2011 · 3 comments
Open

yaml_db 0.2.1 incompatible with YAML engine 'psych' #18

gamov opened this issue May 3, 2011 · 3 comments

Comments

@gamov
Copy link

gamov commented May 3, 2011

Hello,
I use Mac OS X to develop and deploy on Linux. On my machine, there is no libyaml installed thus Ruby uses 'syck' as a yaml engine, but on Linux, it uses 'psyck' because libyaml is present.

yaml_db works perfectly with 'syck' but I noticed it fails with 'psyck' for me.

Dumping with yaml_db
psych:

- - 2
  - ! '40, Obama road , #04-03  Building'
  - Singapore
  - 234332
  - SG
  - !!null

syck:

  - - 2
    - "40, Obama road , #04-03  Building"
    - Singapore
    - 577185
    - SG
    -

Loading
yaml_db doesn't complain while dumping but those difference make yaml_db:load fail.

 You have a nil object when you didn't expect it!
 You might have expected an instance of Array.
 The error occurred while evaluating nil.each
 /usr/local/rvm/gems/ruby-1.9.2-p180/gems/yaml_db-0.2.1/lib/serialization_helper.rb:85:in `load_records'

it's easily reproducible (ruby 1.9.2 / rails 3.0.7):

rvm package install libyaml
rvm remove 1.9.2
rvm install 1.9.2
rails new my_app
cd my_app
rails g scaffold users name:string role:string
rake db:migrate
rake db:fixtures:load
rake db:dump 
rake db:load

`
Solution
Could force the parser to use syck: YAML::ENGINE.yamler= 'syck'
but if user has selected his parser, this might erase his setting. Is there a way to backup user parser to put it back in place? If there is an exception is it bad?

http://stackoverflow.com/questions/4980877/rails-error-couldnt-parse-yaml

@kcrawford
Copy link

+1

@ianneub
Copy link

ianneub commented Aug 19, 2011

+1 here too.

@jerefrer
Copy link

+1 also :)

And I can't manage to make it work using the config/boot.rb fix. Still gets the same error.

Edit : Ok got it. You also have to DUMP using Syck :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants