Reputation: 672
When I try to cleanup my rails versions with sudo gem cleanup rails
I get the following error:
Cleaning up installed gems...
Attempting to uninstall rails-2.3.5
Unable to uninstall rails-2.3.5:
Gem::InstallError: cannot uninstall, check `gem list -d rails`
Attempting to uninstall rails-1.2.6
Unable to uninstall rails-1.2.6:
Gem::InstallError: cannot uninstall, check `gem list -d rails`
gem list -d rails
results in:
rails (2.3.8, 2.3.5, 1.2.6)
Author: David Heinemeier Hansson
Rubyforge: http://rubyforge.org/projects/rails
Homepage: http://www.rubyonrails.org
Installed at (2.3.8): /Library/Ruby/Gems/1.8
(2.3.5): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
(1.2.6): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Web-application framework with template engine, control-flow layer,
and ORM.
Any one know what's wrong?
Upvotes: 6
Views: 3345
Reputation: 672
After some long searches it turns out the reason is because of a non-existent path. The cannot uninstall comes up because the system doesn't search /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
On a granular level, instead of gem cleanup rails
, you can simply use the uninstall command and type:
gem uninstall rails -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Then you might hit another problem related to a non-existent path, at which point, you should create a directory using the command:
mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/bin
Now all uninstalls should work well. I recommend doing a clean gem reinstall by performing the following functions:
gem list --no-versions | sed -e '/^(*|$)/d' > installed_gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
cat installed_gems | xargs sudo gem install
Upvotes: 13
Reputation: 3665
Check out http://gabrito.com/post/mac-os-x-gem-cleanup-failing, proposing:
sudo sh -c 'GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 gem cleanup'
Upvotes: 1