Syck.dump empty hash throws IO exception

38 views Asked by At

I am busy writing a data migration which is going to allow us to change yamlers from Syck, to Psych. For this I need to migrate some columns in our data base. I have hit the following weird edge case

 (rdb:1) Syck.dump({})
    *** NoMethodError Exception: undefined method `[]' for #<StringIO:0x007f9142eb7438>
/Users/donovanthomson/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/psych/deprecated.rb:21:in `quick_emit'
/Users/donovanthomson/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `to_yaml'
/Users/donovanthomson/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/syck/rubytypes.rb:451:in `to_yaml'
/Users/donovanthomson/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/syck.rb:119:in `dump'

So apparently empty hashes can not be dumped using Syck ?

1

There are 1 answers

0
Donovan Thomson On

Turns out I was doing something pretty stupid, I had removed the Syck dependency locally before I had run the migration.