How to Reinstall the Ruby Gems
Ruby libraries, called gems, are often distributed using a special format and package-management program called gem. However, the command line, non-graphical user interface for the gem program can make it difficult to know how to perform some basic operations on gems, such as performing a reinstall.
Instructions
-
-
1
Open a command prompt. How to do this will vary a great deal depending on your operating system. In Windows, click "Start," "Run" and type "cmd" in the dialog that comes up. In Mac OS X, press "Cmd-Space" on the keyboard to open Spotlight, type "terminal" and press "Enter." The steps for opening a terminal in Linux varies a great deal depending on your flavor of Linux and configuration, so if you are unsure how, consult the documentation.
-
2
Uninstall the gem. This is necessary before you can reinstall the gem. Type the following into the command prompt:
gem uninstall gem-name
Replace "gem-name" with the name of the gem that you wish to reinstall. On Mac OS X and Linux machines, depending on your configuration, you may need to type the following instead to run the command with "superuser" access if the above command fails with a "write permissions" error:
sudo gem uninstall gem-name
-
-
3
Reinstall the gem by typing the following:
gem install gem-name
Once again, you should replace gem-name with the name of the gem that you want to reinstall and if you are on a Mac OS X or Linux computer and are logged in as a normal user rather than as a system administrator, you will need to preface the line with the "sudo" command, like so:
sudo gem install gem-name
-
1
Tips & Warnings
You can type "gem help commands" from the command line to get a list of all of the commands that you can use to interact with Ruby gems using the gem package manager.
If you simply wish to update your gems to the latest version, it usually is not necessary to reinstall the gems entirely. You can use "gem update" to update all of your gems automatically or "gem update gem-name" to update a selected gem.
References
- Photo Credit Jupiterimages/Photos.com/Getty Images