Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninitialized constant Psych::Syck on gem install

Tags:

ruby

rubygems

I pushed a gem up to rubygems.org, and when I do a 'gem install (gem)' I get this error:

ERROR:  While executing gem ... (NameError)
uninitialized constant Psych::Syck

I can do a 'gem build (gem).gemspec' to generate a local gem and then gem install (gem).gem and that installs fine. I can also put the gem into my Rails' app's Gemfile with a pointer to the Github repo and that will also work. I have tried installing the gem (from rubygems.org on multiple computers and they all get the same error.

I am out of ideas as to what can be causing the install to fail when done from rubygems.org but not when I generate it locally. I am using Jeweler to push the gem up to rubygems.org.

like image 215
jnevelson Avatar asked Jul 06 '11 04:07

jnevelson


3 Answers

The specific error I got was: uninitialized constant Psych::Syck (NameError) when doing bundle install.

This happened when installing simplecov (awesome code coverage tool) version 0.5.0. Working in Ubuntu 11.04 and using RVM.

Fixed the issue with gem update --system

This updates rubygems and produced the following output:

Updating rubygems-update
Fetching: rubygems-update-1.8.10.gem (100%)
Successfully installed rubygems-update-1.8.10
Installing RubyGems 1.8.10
RubyGems 1.8.10 installed

== 1.8.10 / 2011-08-25

RubyGems 1.8.10 contains a security fix that prevents malicious gems from
executing code when their specification is loaded.  See
https://github.com/rubygems/rubygems/pull/165 for details.

* 5 bug fixes:

* RubyGems escapes strings in ruby-format specs using #dump instead of #to_s
  and %q to prevent code injection.  Issue #165 by Postmodern
* RubyGems attempt to activate the psych gem now to obtain bugfixes from
  psych.
* Gem.dir has been restored to the front of Gem.path.  Fixes remaining
  problem with Issue #115
* Fixed Syck DefaultKey infecting ruby-format specifications.
* `gem uninstall a b` no longer stops if gem "a" is not installed.


------------------------------------------------------------------------------

RubyGems installed the following executables:
    /home/baller/.rvm/rubies/ruby-1.9.2-p180/bin/gem

RubyGems system software updated
like image 53
B Seven Avatar answered Nov 15 '22 10:11

B Seven


Seems to be a problem with Syck. See here:
Rails 3.1 on Ubuntu 11.04 via RVM - uninitialized constant Psych::Syck

Here:
http://rubyforge.org/tracker/?group_id=126&atid=575&func=detail&aid=29163

And fixes suggested here:
https://github.com/rubygems/rubygems/pull/57

like image 45
Casper Avatar answered Nov 15 '22 12:11

Casper


The solution would be to run the below command in your terminal:

gem update --system

It is a bug in the system gem version that causes this issue. This worked for me.

like image 32
karthiks Avatar answered Nov 15 '22 10:11

karthiks