Ruby Gem

Description

RubyGemsopen in new window is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a gem), a tool designed to easily manage the installation of gems, and a server for distributing them.

The interface for RubyGemsopen in new window is a command-line tool called gem which can install libraries and manage RubyGemsopen in new window. RubyGemsopen in new window integrates with Ruby run-time loader to help find and load installed gems from standardized library folders. Though it is possible to use a private RubyGems repository, the public repository is most commonly used for gem management.

Usage

If you’re on Ruby 2.4.1 (what we’re using now), then you don’t have to worry about installing RubyGems, it’s built in. If you don't have it just head over to the RubyGems download pageopen in new window, download the ZIP, open it up, and run ruby setup.rb in the terminal.

If you think you might already have RubyGems installed, run gem -v to get the version number. The latest version is 2.6.14 If you’d like to upgrade, run gem update --system.

So, now that you’ve got the RubyGems library installed, you can use it to install whatever gems you please. It’s pretty simple. The hard part is finding the gem you’d like to use; often, you can just google for whatever functionality you’re looking for. Once you find the gem, install it like this:

    gem install GEM_NAME
1

It’s important to pay attention to the documentation for the gem, though. There may be some arguments you should add to that command; however, in most cases, that should get you through.

If you want to get more information about a gem:

    gem spec GEM_NAME
1

To see what gems are installed:

    gem list
1

By default, gem list and gem spec use the --local option, which forces gem to search only the local system. This can be overridden with the --remote flag:

    gem list --remote GEM_NAME
1

To update all installed gems:

    gem update
1