Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant Psych::Syck (NameError)

In my gem i require yaml and works great on my computer locally.

But after pushing my gem into rubygems.org and when i try to use my gem i get an error saying => "uninitialized constant Psych::Syck (NameError)"

Can anyone help me to fix this problem?

P.S.

Ruby Version => ruby 1.9.2,
Gem Version => 1.6.2,
Bundler version => 1.0.15
like image 201
Manish Das Avatar asked Aug 04 '11 06:08

Manish Das


1 Answers

After several hours of research I found that => "YAML uses the unmaintained Syck library, whereas Psych uses the modern LibYAML"

So in order to resolve that error, I had to update my gem (gem update --system i.e. 1.8.6) and rescue the LoadError thrown by Psych before requiring yaml, something like this:

begin
 require 'psych'
 rescue ::LoadError
end

require 'yaml'

Source:

  • http://pivotallabs.com/users/mkocher/blog/articles/1692-yaml-psych-and-ruby-1-9-2-p180-here-there-be-dragons

  • http://opinionatedprogrammer.com/2011/04/parsing-yaml-1-1-with-ruby/

like image 108
Manish Das Avatar answered Sep 17 '22 04:09

Manish Das