By: Dusty Arlia
Published on Tuesday, July 8, 2014, 09:21 PM
Last Updated on Friday, July 10, 2015 at 12:08 AM
Total Updates: 2

Gems are packages that contain package information along with files to install. They are usually built from .gemspec files, which are YAML files containing information on Gems. However, Ruby code may also build Gems directly. Such a practice is usually used with Rake.

The gem command is used to build, upload, download, and install Gem packages. Here are some examples:


gem install mygem


gem uninstall mygem

Listing installed gems:

gem list --local

Listing available gems, e.g.:

gem list --remote

Create RDoc documentation for all gems:

gem rdoc --all

Download but do not install a gem:

gem fetch mygem

Search available gems, e.g.:

gem search STRING --remote

The gem command may also be used to build and maintain .gemspec and .gem files. Here is an example:

Build .gem from a .gemspec file:

gem build mygem.gemspec