Ruby Gems can be a little interesting to manage, especially to someone as new to it as I am. In the course of my own self-education, I’ve compiled a little list of what I consider the basic commands. Hopefully this will be of some help to others as well.

Gem Sources

To see which gem servers or repositories your installation of RubyGems is using, open a command prompt and type:

gem sources

The system will return with a list of the repositories and caches Ruby is using to look for gems. In the case of my local system, I got back:

C:>gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org/

Which shows that my system is only looking at RubyForge for its gems right now. This can be useful to know if you get errors that gems cannot be found.

Installing Gems

To install a new gem, you can open a command prompt and type:

gem install gemname

This will install the latest version of the gem gemname from the repository(ies) your local system knows about.

If you have a local copy of the gem and you need to install that particular one, you can open a command prompt, navigate to the directory that contains the local copy and type:

gem install gemname --local

If you need only a particular version of a gem that might not be the latest version you’d get by default, you can open a command prompt and type:

gem install gemname --version #.#.#

This will install version #.#.# of gem gemname.

Uninstalling Gems

Uninstalling a gem can be done by opening a command prompt and typing:

gem uninstall gemname

This will uninstall the gem gemname. If you have more than one version of that gem installed, RubyGems will display a numbered list of the versions and you can enter the number of the version you want to uninstall or choose to uninstall all versions of gem gemname.

Updating Gems

You can update installed gems by opening a command prompt and typing:

gem update gemname

This will update the gem gemname to the latest version in the gem repository RubyGems is pointing to.

Updating the RubyGems System

Sometimes you will need to update the actual RubyGems management system. To do this, open a command prompt and type:

gem update --system

If you are having problems updating your gems or using them, it usually won’t hurt to try to do this update.

Check Gem Dependencies

If you need to know what the dependencies of an installed gem are, you can open a command prompt and type:

gem dependency gemname

This will list the dependencies of the gem gemname.

Gem Help

There is a good amount of help embedded in the RubyGems system. Often you can answer your own questions on how to manipulate your gems using this help. To access the list of commands, open a command prompt and type:

gem help commands

To get help on an individual command, open a command prompt and type:

gem help command