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. Pingback: Ruby Gems errors oplossen (updaten en cleanen) | Daniel van Dorp