Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Rails Error "invalid gem: package is corrupt"

Tags:

I am running Mac OSX 10.9.1 and I am using RVM to manage Ruby v2.0.0-p353.

When I try to install Rails I get this error:

Ryans-MacBook-Air-2:~ ryan$ gem install rails
ERROR:  Error installing rails:
invalid gem: package is corrupt, exception while verifying: undefined method`path2class' for #<Psych::ClassLoader:0x0000010c9d0be0> (NoMethodError) in /Users/ryan/.rvm/gems/ruby-2.0.0-p353/cache/i18n-0.6.9.gem

Here is a list of gems I have installed:

Ryans-MacBook-Air-2:~ ryan$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.3, 1.2.0)
bundler (1.5.1)
bundler-unload (1.0.2)
executable-hooks (1.2.6)
gem-wrappers (1.2.1)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (5.2.0, 4.3.2)
psych (2.0.2, 2.0.0)
rake (10.1.1, 0.9.6)
rdoc (4.1.0, 4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.8)
test-unit (2.5.5, 2.0.0.0)

Does anyone have suggestions to fix this?

like image 725
ryan Avatar asked Dec 31 '13 02:12

ryan


2 Answers

The latest version no longer has the class2path method so the problem can be avoided by downgrading the Psych gem to version 2.0.0:

gem list psych   # note down latest version
gem uninstall psych -v 2.0.5  # or whatever version you have installed

After the gems are installed you can upgrade the Psych gem again should you need it.

like image 147
Jan M Avatar answered Sep 23 '22 07:09

Jan M


I had this exact issue as well with the exact environment as you. I tried many things including the link which Alexbhandari added to the comment. I spent hours and finally decided to call it quits and totally wipe all of the ~/.rvm folder and start again.

Warning: this should only be done for new installs without first considering what you might lose things, such as as gemsets you may have built yourself. If however it is a new install you will not loose anything that cannot be replaced.

I renamed the ~/.rvm folder so that I did have a backup and started the whole install process again. This time it worked and I was actually up and running within about 20 minutes as opposed to the hours I had wasted prior trying to fix the issue.

You do this from the terminal window with the mv command. The ~/.rvm directory was in my $home directory:

Stephens-MacBook-Pro-2:~ Steve$ mv .rvm old.rvm

I know this is a drastic step however it worked for me on a new install so I am hoping it will help a newby in the future.

like image 40
Steve Avatar answered Sep 21 '22 07:09

Steve