Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstalling rails and gems, getting error "cannot uninstall, check 'gem list -d ...'

I'm going to start with the usual noob line, "I'm new to rails". Oh, and I'm running Mac OSX 10.6.4

I've been following a bunch of guides to get set up, specifically these two here and here. The guides are great, the reason I'm using the second one is because of RVM and the reason I'm using the first is for MYSQL.

Anyway, when I started, I wasn't following the directions completely and so after I installed RVM, for some reason I installed rails with sudo gem install rails -v 2.3.8 because thats the version I need. So... I realized I was using the system ruby, and wasn't taking advantage of RVM. What I did now was install Ruby 1.9.2 so I can install rails 3 and test it out, and I also installed 1.8.7 and rails 2.3.8 so I can use it for what I need it.

Now, I'm trying to uninstall the gems from the system Ruby, but whenever I try to I'm getting this error:

ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check 'gem list -d whatever gem I try to uninstall'

Any ideas on how to remove rails and all these gems? I just want to start from scratch with RVM.


UPDATE:

By running the command gem list -d rails I've located the gems in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/18. Should I delete them manually?

like image 918
GiH Avatar asked Oct 24 '10 03:10

GiH


People also ask

How do I uninstall and reinstall a gem?

If you've installed into ./bundle/vendor or similar, you need to remove the gem first but explicitly specify the GEM_HOME, e.g. This is by far the simplest way to uninstall gems installed using bundler into a vendor directory. Ideally, there would be a command bundle uninstall or bundle reinstall , etc.


1 Answers

SOLUTION!! I still don't understand why this happened, I'd love if someone could explain. Why was the path non-existant? What caused this error?

Also, I want to mention that the solution I linked to has a comment saying that the question is a duplicate. However, the original has a different solution and did not help me (though its the basis to finding this answer). Simply deleting the gems manually in finder would not remove them from the gem list.

Without further ado - it turns out that when trying to uninstall the gem, it can't locate its path (I think the problem is because of installing with sudo, but I might be wrong). What you need to do is (you have to do this one by one for each gem, or at least I had to):

  1. gem list -d 'name of gem' and note the "Installed at:" location (in my case, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8)
  2. sudo gem uninstall 'name of gem' -i 'the path noted above' (ex. in my case, sudo gem uninstall rails -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  3. Some gems still might not uninstall returning a permissions error. If this is the case, what you need to do is create a folder /bin, in the path above. (in my case, mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/bin
  4. Continue uninstalling as in step 2, still using the original path (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8).

Now all uninstalls should work!

like image 163
GiH Avatar answered Oct 21 '22 14:10

GiH