RubyGems - Ruby Package Utility


RubyGems is a package utility for Ruby, which installs Ruby software packages and keeps them up-to-date.

Usage Syntax

$ gem command [arguments...] [options...]


Check to see whether RubyGems is installed −

$ gem --version

RubyGems Commands

Here is a list of all important commands for RubyGems −

Sr.No. Command & Description
1 build

Builds a gem from a gemspec.

2 cert

Adjusts RubyGems certificate settings.

3 check

Checks installed gems.

4 cleanup

Cleans up old versions of installed gems in the local repository.

5 contents

Displays the contents of the installed gems.

6 dependency

Shows the dependencies of an installed gem.

7 environment

Displays RubyGems environmental information.

8 help

Provides help on the 'gem' command.

9 install

Installs a gem into the local repository.

10 list

Displays all gems whose name starts with STRING.

11 query

Queries gem information in local or remote repositories.

12 rdoc

Generates RDoc for pre-installed gems.

13 search

Displays all gems whose name contains STRING.

14 specification

Displays gem specification (in yaml).

15 uninstall

Uninstalls a gem from the local repository.

16 unpack

Unpacks an installed gem to the current directory.

17 update

Updates the named gem (or all installed gems) in the local repository.

RubyGems Common Command Options

Following is the list of common options −

Sr.No. Command & Description
1 --source URL

Uses URL as the remote source for gems.

2 -p, --[no-]http-proxy [URL]

Uses HTTP proxy for remote operations.

3 -h, --help

Gets help on this command.

4 --config-file FILE

Uses this config file instead of default.

5 --backtrace

Shows stack backtrace on errors.

6 --debug

Turns on Ruby debugging.

RubyGems Install Command Options

This is a list of the options, which use most of the time when you use RubyGems while installing any Ruby package −

Sr.No. Command & Description
1 -v, --version VERSION

Specifies version of gem to install.

2 -l, --local

Restricts operations to the LOCAL domain (default).

3 -r, --remote

Restricts operations to the REMOTE domain.

4 -b, --both

Allows LOCAL and REMOTE operations.

5 -i, --install-dir DIR

Where to install.

6 -d, --[no-]rdoc

Generates RDoc documentation for the gem on install.

7 -f, --[no-]force

Forces gem to install, bypassing dependency checks.

8 -t, --[no-]test

Runs unit tests prior to installation.

9 -w, --[no-]wrappers

Uses bin wrappers for executables.

10 -P, --trust-policy POLICY

Specifies gem trust policy.

11 --ignore-dependencies

Do not install any required dependent gems.

12 -y, --include-dependencies

Unconditionally installs the required dependent gems.


This will install 'SOAP4R', either from local directory or remote server including all the dependencies −

gem install soap4r --include-dependencies

This will install 'rake', only from remote server −

gem install rake --remote

This will install 'rake' from remote server, and run unit tests, and generate RDocs −

gem install --remote rake --test --rdoc --ri

Further Readings

  • The RubyGems User Guide gives you almost everything you need to know about using RubyGems.

  • The RubyGems Command Reference for RubyGems.