How to uninstall / remove Ruby Gems (on Ubuntu)?

First we need to find out the exact location that the Ruby installs it’s libraries. In the terminal program, You can type the following command to find out the exact location.
You’ll get list of paths. This is the output that I got in my machine.
/usr/local/lib/site_ruby/1.8/i486-linux
/usr/local/lib/site_ruby/1.8/i386-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i486-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i486-linux
/usr/lib/ruby/1.8/i386-linux
.
Next we need to change our directory in to /usr/local/lib/site_ruby/1.8 and type following command to list the files.
drwxr-xr-x 3 root root 4096 2009-07-15 12:14 ..
-rw-r--r-- 1 root root 1415 2009-07-15 12:15 gauntlet_rubygems.rb
drwxrwsr-x 2 root staff 4096 2009-07-15 12:14 i486-linux
drwxr-xr-x 2 root root 4096 2009-07-15 12:15 rbconfig
drwxr-xr-x 6 root root 4096 2009-07-15 12:15 rubygems
-rw-r--r-- 1 root root 29116 2009-07-15 12:15 rubygems.rb
-rw-r--r-- 1 root root 268 2009-07-15 12:15 ubygems.rb
Now we are ready to remove the gems. Type,
If you wish to remove all gems installed in your computer, first find out the location by executing following commands
Next you can remove them by using following commands. That’s it!
rm -r /usr/bin/gem1.8
Related Articles
Tags: Gem, How to, Ruby on Rails, Web Development
This entry was posted on Wednesday, July 22nd, 2009 at 5:14 pm and is filed under How to, Ruby on Rails, Tutorials, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.


22nd July, 2009
Another good one, Aslam.
A little addition here. If you wish to get rid of all the gems (or the complete Ruby installation), it is best to uninstall all the installed gems first. This is because some gems place executables outside the Ruby installation (Eg: directories within $PATH). So if you just delete the Ruby installation, these files become stale and might cause problems in future.
You can find more information about your RubyGems environment by the command:
$ gem env
There we couple of more things in the case you are completely wiping a Ruby installation (Eg: to setup a new one). Unfortunately I cannot remember those. If I run into then again, I’ll comment here.
Keep it up.
22nd July, 2009
Thank you very much for your feedback Gaveen!
Yeah! If can, please comment the exact steps. Waiting to read that!
7th September, 2009
very good thing…i learned lot friom your posts…..all the best…
6th December, 2009
Thanks, got those removed.
8th January, 2010
how to uninstall ruby 1.8 from ubuntu
9th January, 2010
Open the terminal and type