Mac OS X gem cleanup failing

Ruby GemsAfter upgrading to Snow Leopard I started noticing that whenever I would run sudo gem cleanup it would fail with many errors about being unable to uninstall various gems. I ignored it until the list grew unbearably long but the only solutions I could find on the web were to go through one gem at a time. The errors looked like this:

...
Attempting to uninstall rails-2.3.5
Unable to uninstall rails-2.3.5:
Gem::InstallError: cannot uninstall, check `gem list -d rails`
...

Following the instructions I then ran gem list -d rails noting the install path for newer gems was now /Library/Ruby/Gems/1.8 whereas the older gems that cleanup was failing on were in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8. So the solution was to run cleanup once while overriding GEM_HOME as follows:


sudo sh -c 'GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 gem cleanup'

That allowed cleanup to remove the older gems in the old path and now sudo gem cleanup is once again working.

This entry was posted in Uncategorized. Bookmark the permalink.

7 Responses to Mac OS X gem cleanup failing

  1. Geoff says:

    Worked like a charm. Thanks!

  2. AC says:

    Thanks! Cleaned it up very nicely.

  3. cashplk says:

    thanks~~

  4. Pingback: Ruby Gems errors oplossen (updaten en cleanen) | Daniel van Dorp

  5. soap says:

    This article is very useful. I have used my Mac for years and did not notice my hard disk is consuming by the useless files. This article helped me much. I also found another free cleanup software. http://www.easemac.com It is free and effective.

  6. soap says:

    This is very useful. It worked for me. Thanks. And I tried to use free MacCleaning to do the cleanup as well.

  7. Tom Patrick says:

    If you are experiencing a slow Mac due to huge amount of junk files present on your Mac HDD then you must pick up Stellar Speed up Mac to clean the junks that are present on your Mac.

Comments are closed.