开发者

uninitialized constant Psych::Syck (NameError)

开发者 https://www.devze.com 2023-03-24 23:14 出处:网络
In my gem i require yaml and works grea开发者_开发问答t 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 const

In my gem i require yaml and works grea开发者_开发问答t 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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消