Knowledge Base

Ruby Gems | How To Install Ruby Gems

This article describes how to install Ruby gems on your account.

These instructions do not apply to servers with cPanel control panel and the Ruby Selector installed. Check for the Setup Ruby App icon in the SOFTWARE section of cPanel before proceeding. If Setup Ruby App is present, use this article.

Installing Ruby gems

You can install gems using the gem command-line program. To do this, follow these steps:

  1. Log in to your account using SSH.
  2. To make sure you are in your home directory, type the following command at the command line:
    cd ~
  3. Use your preferred text editor to edit the .bash_profile file in your home directory. The .bash_profile file should contain the following configuration:

    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    # Set paths for Ruby gems:
    # END
  4. Save your changes to the .bash_profile file.
  5. To make the settings in the .bash_profile file take effect immediately, type the following command:

    source ~/.bash_profile
  6. To create a directory for your local gems, type the following command:

    mkdir -p ~/ruby/gems
  7. Use your preferred text editor to create a .gemrc file in your home directory. The .gemrc file sets the GEM_PATH and GEM_HOME variables that are used by the gem program. The gemhome value is set to the full path where the gems will be installed (this is the directory that you created in step 6). The gempath values are set to the gemhome directory, as well as to the system-wide base gems directory. The following text shows an example .gemrc file. Replace username with your own A2 Hosting account username:

    gemhome: /home/username/ruby/gems
    - /home/username/ruby/gems
    - /usr/lib/ruby/gems/1.8
  8. To verify that the gem environment has been updated, type the following command:

    gem environment

    The output should display GEM PATHS with the values that you set in the .gemrc file.

  9. To install a gem, type the following command. Replace gemname with the name of the gem that you want to install:

    gem install gemname

    For example, to install the sass gem, type gem install sass.

    To uninstall a gem, type the following command:

    gem uninstall gemname

More Information

About Ruby Gems

What Are RubyGems?

ruby gemsRubyGems is a package management system used with the Ruby programming language. RubyGems provide users with a standard format for distributing Ruby libraries and programs. Essentially, RubyGems makes it easier for users to download, install and use Ruby software packages. The actual software package is called a gem. The gem includes the actual packaged Ruby library or application.

Ruby applications can be customized, extended or modified through the use of gems. They're designed to make development easier by focusing on re-usability, as well automate tasks for more rapid development.

Ruby Gems History

Richard Kilmer, Paul Brannan, David Alan Black, Jim Weirich and Chad Fowler began development of RubyGems back in late November 2003. RubyGems were officially released on March 14, 2004. RubyGems have been available since v1.8, but didn't become a standard part of Ruby until v1.9.