Ruby Gems : Lucy In The Sky With Gems

Python has its eggs, Java has its jars and ruby has its gems. So a gem is a ruby package, containing some library or executable program. In the previous two chapters about RVM and Rbenv I installed rails using the gem command. Since ruby 1.9, Ruby Gems comes with ruby. So, how to use it?

  1. You can list all the available gems, hosted on with:

    gem query --remote (gem q -r)
    gem list -r

  2. You can search for remote gems with:
    gem query --remote --name-matches <name>
    gem search -r <name>
    gem search <name>
    gem sea <name>
  3. You can install a gem using:
    gem install --remote <name>
    gem install <name>
    gem ins <name>
  4. You can install a given version of a gem using:
    gem install --remote <name> --version <version>
    gem install <name> --version <version>
    gem ins <name> --version <version>
    or like that
    gem install <name>-<version>

    For versions you can use  operators :

    gem install <name> --version "= 0.1.3"  
    All operators:
      =  Equals version
      != Not equal to version
      >  Greater than version
      <  Less than version
      >= Greater than or equal to
      <= Less than or equal to
      ~> Approximately greater than 

    To see all available versions of a gems:

    gem search -a <name>
    gem list -r -a
  5. To see the locally installed gems:
    gem list (-l)
    gem query -l (--local)

    To search in the locally installed gems for given gem:

    gem search -l <name>

    A detailed information for an installed gem:

    gem specification <name>

    This can be executed with the ‘-r’ option for remote gem.
    A cool feature is to run

    gem server

    And to use your browser, opening http://localhost:8808 to browse detailed information for your installed gems.

  6. To uninstall a gem:
    gem uninstall <name>
  7. You can install gems with options like ‘–no-rdoc or ‘no-ri’, see all available using:
    gem help install

    You can put a .gemrc file in your home with some commands and settings to be used with Ruby Gems. The file should look like this:

      gem:  --local --no-rdoc --run-tests
        - /usr/share/rubygems
        - /home/meddle/.stuff

    Read for more here

I think this is a good manual for the tool, we will use it a lot in the up-coming posts.

Useful Links:

  1. Ruby Gems site –
  2. Ruby Gems docs –
  3. Manual at –

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s