Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean install OSX 10.9.1 returns "undefined method `path2class'" when trying to install gems

I just installed a clean Mavericks installation with Homebrew and RVM. Both brew doctor and rvm requirements return "all good", however, when I run bundle install in my project dir most of my gems install fine, but a handful fail to install with the same following error:

Bundler::GemspecError: Could not read gem at /Users/NK/.rvm/gems/ruby-2.0.0-p353/cache/eventmachine-1.0.3.gem. It may be corrupted.
An error occurred while installing eventmachine (1.0.3), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.3'` succeeds before bundling.

Then, if I try again with gem install eventmachine -v '1.0.3' I get:

ERROR:  Error installing eventmachine:
    invalid gem: package is corrupt, exception while verifying: undefined method `path2class' for #<Psych::ClassLoader:0x000001018f7990> (NoMethodError) in /Users/NK/.rvm/gems/ruby-2.0.0-p353/cache/eventmachine-1.0.3.gem

I tried to implode RVM and reinstall, but nothing helps.

Other people seem to have the same problem, but no one seems to have fund the answer yet:

  • http://pastebin.com/LV53GdR2
  • Install Rails Error "invalid gem: package is corrupt"
  • Error install rubyracer with error "invalid gem: package is corrupt"

EDIT

See those two as well:

  • https://github.com/tenderlove/psych/issues/182
  • https://github.com/wayneeseguin/rvm/issues/2620
like image 703
Niels Kristian Avatar asked Feb 11 '14 00:02

Niels Kristian


2 Answers

It turns out that this is a bug in an older version of psych, but it can't be solved, as long as you installed ruby with RVMs statically linked gems. So basically the problem is related to RVMs statically linked gems. Installing rubies with the --disable-binary solves the problem:

rvm install 2.0.0-p353 --disable-binary

Or reinstall with:

rvm reinstall 2.0.0-p353 --disable-binary
like image 61
Niels Kristian Avatar answered Nov 05 '22 01:11

Niels Kristian


I had the very same error and looked into the psych gem

$ gem list --local | grep psych
psych (2.0.4, 2.0.0)

as version 2.0.4 was recently installed I removed it, keeping only version 2.0.0

$ gem uninstall psych -v '2.0.4'
Successfully uninstalled psych-2.0.4

After that, everything worked fine again!

like image 22
Niklas B. Avatar answered Nov 04 '22 23:11

Niklas B.