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

Uninstall Ruby

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.

ruby -e 'puts $:'

You’ll get list of paths. This is the output that I got in my machine.


Next we need to change our directory in to /usr/local/lib/site_ruby/1.8 and type following command to list the files.

ls -la

drwxr-xr-x 5 root root 4096 2009-07-15 12:15 .
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,

rm -r rubygems.rb ubygems.rb rubygems

If you wish to remove all gems installed in your computer, first find out the location by executing following commands

which gem gem1.8

Next you can remove them by using following commands. That’s it!

rm -r /usr/local/bin/gem
rm -r /usr/bin/gem1.8