views:

1588

answers:

4

I've got a few ruby gems that won't go away.

I think it has to do with when I installed them. Occasionally I have forgotten to use "sudo" before doing a gem install, which results in a write error and from what I can gather puts a copy of the gem in my user directory instead of somewhere it can run. But gem uninstall doesn't work. It continually shows up in 'gem list' but can't uninstall it from either gem uninstall, or sudo gem uninstall. I tried directly deleting one gem after finding the path in my 'gem environment', but that still left the gem on the list.

Also is it possible just to remove all gems and start from scratch? These are driving me nuts.

I'm running OS X.

Thanks,

+7  A: 

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

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

gem env paths

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

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

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

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

Olly
worked like a charm... thanks.
holden
one follow up question... when i install gems via rails with rake gems:install will they get installed properly? or should i also run sudo rake gems:install?
holden
I guess that depends which Ruby installation you're using and how that was installed. If you installed it from source, chances are you'll need to run `sudo rake gems:install`. I'd generally favour the sudo option in most cases
Olly
A: 

update your version of ruby gems gem update --system then hopefully gem uninstall xxx will work right now [was a bug in older versions]

rogerdpack
A: 

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

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

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

Bitterzoet
A: 

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

Dan McNevin