How to Uninstall a Ruby Gem

Techwalla may earn compensation through affiliate links in this story.

Features can be added to the Ruby programming language by downloading and installing special packages called gems. These packages are fetched from a central repository by a program named "gem," which normally comes with Ruby. Most Ruby programmers are immediately familiar with the steps needed to install a Ruby gem, but may not be familiar with how to remove gems that are no longer needed from the system. This can be accomplished using a special command of the Gem package manager.


Step 1

Open a terminal. In Windows, you can do this by clicking "Start" and "Run." When the "Run" dialog appears, type "cmd." On Mac OS X, you can simply click the Spotlight button and type "Terminal."

Step 2

Type the following command to uninstall a gem:

gem uninstall GEMNAME

Replace "GEMNAME" with the name of the gem you would like to install.


Step 3

Answer any prompts given by the uninstall command. Depending on the configuration of the gem itself, you may be asked to specify the versions to uninstall or asked to confirm the uninstallation. In addition, the uninstall may fail if the gem detects that other gem packages depend on the one you wish to uninstall.


You can force a gem to uninstall despite warnings that gem may give you about dependencies by adding a "-i" (for "ignore") to the command.

If you have forgotten the full name of the gem you would like to uninstall, you can type the command "gem list" to list all the installed gems on your system.