[ACCEPTED]-getting rid of ruby gems that won't die-rubygems

Accepted answer
Score: 31

Assuming that gem clean (or sudo gem clean) doesn't work, I would 9 try the following to totally remove all 8 gems from your system:

You can see where 7 gems have been installed by running the 6 command:

gem env paths

To remove all the gems on your system, simply 5 remove the folders returned by this command.

Additionally, on 4 OSX Leopard, default gems are installed 3 in this folder:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

If this folder exists on 2 your system, as before you can remove this 1 folder to ensure all gems are deleted.

Score: 12

You could also do the following to get rid 3 of installed gems.

gem list -d [gem name]
gem uninstall --install-dir [install directory] [gem name]

if the before mentioned 2 things don't work, I had to do it myself 1 today.

Score: 8

I had a similar issue, but the root problem 5 turned out to be gemspecs that were sticking 4 around for some unknown reason.

After I thought 3 I had uninstalled all gems:

matt$ gem1.9 list
*** LOCAL GEMS ***
minitest (1.6.0)
rake (0.8.7)
rdoc (2.5.8)

No gems here:

matt$ ls -al /opt/local/lib/ruby1.9/gems/1.9.1/gems/
total 0
drwxr-xr-x  2 root  admin   68 Jul 23 14:54 .
drwxr-xr-x  8 root  admin  272 Mar  3 14:56 ..

There 2 they are!

matt$ ls -al /opt/local/lib/ruby1.9/gems/1.9.1/specifications/
total 24
drwxr-xr-x  5 root  admin  170 Jul 23 14:54 .
drwxr-xr-x  8 root  admin  272 Mar  3 14:56 ..
-rw-r--r--  2 root  admin  129 Nov  1  2010 minitest.gemspec
-rw-r--r--  2 root  admin  121 Nov  1  2010 rake.gemspec
-rw-r--r--  2 root  admin  121 Nov  1  2010 rdoc.gemspec

Remove the gemspecs:

matt$ sudo rm /opt/local/lib/ruby1.9/gems/1.9.1/specifications/*

And now the 1 gems are gone:

matt$ gem1.9 list
*** LOCAL GEMS ***
Score: 3

I had a gem that would not die and had to 3 go the "nuke everything" route by deleting 2 all my gems with the command gem uninstall -aIx. Then just 1 gem install <gemname> and I was back up and running.

Score: 2

If you have multiple versions of a gem, you 2 will have to first do a clean up and then 1 delete the final gem.

 gem cleanup <gemname>
 gem uninstall <gemname> --version
Score: 0

Update your version of ruby gems by running 2 gem update --system and then, hopefully, gem uninstall xxx will work. [It was 1 a bug in older versions.]

Score: 0

Check out RVM, it allows you to completely 4 manage your ruby environment under your 3 user rather than in a system directory. I've 2 found it much easier to manage ruby versions 1 and gems using it.

More Related questions