13

When trying to install therubyracer on OSX 10.9, with the command:

$ gem install therubyracer -v '0.12.0'

I get the error:

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

XCode developer tools are installed, and I've tried removing the cache file, but I still get the error.

Oved D
  • 7,132
  • 10
  • 47
  • 69

2 Answers2

27

Delete /Users/doved/.rvm/gems/ruby-2.0.0-p353/cache/therubyracer-0.12.0.gem and install the gem again. RubyGems didn't download the file properly, and the system is properly reporting that the gem is corrupted.

frandroid
  • 1,343
  • 16
  • 26
  • 2
    I had same error with nokogiri-1.6.4 and `rm /Users/username/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/cache/nokogiri-1.6.4.gem` helped me. Thanks! – Stepan Zakharov Nov 20 '14 at 10:31
  • 1
    I had same error with libv8 and `rm /home/siva/.rvm/gems/ruby-2.2.0/cache/libv8-3.16.14.7-x86_64-linux.gem` worked for me. – Siva Gollapalli Jan 01 '15 at 14:21
0

I had the following issue :

Bundler::GemspecError: Could not read gem at /home/username/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/cache/nokogiri-1.6.6.3.gem. It may be corrupted.

Then to fix this I had to go to the following directory : /home/username/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/cache

Then I removed the corrupted gem, i.e Nakogiri in my case.

Then I ran the following command : gem install nokogiri -v '1.6.6.3'

After installing the gem again, I was good to go.

Tom
  • 22,301
  • 5
  • 63
  • 96
Sagar
  • 1