Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem::Install Error

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?

like image 709
Tian Avatar asked Jun 15 '10 21:06

Tian


People also ask

How do I fix a run bundle to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

How do I know if gem is installed?

To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.

What is GEM file in Ruby?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.


1 Answers

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:

create a list of all existing gems

gem list --no-versions | sed -e '/^(*|$)/d' > installed_gems

uninstall all existing gems

gem list | cut -d" " -f1 | xargs gem uninstall -aIx

reinstalling latest gems

cat installed_gems | xargs sudo gem install

like image 116
Tian Avatar answered Oct 28 '22 20:10

Tian