Home > Ruby on Rails, RubyGems > HOWTO: installing, updating and removing rubygems

HOWTO: installing, updating and removing rubygems

April 9th, 2008

 Powered by Max Banner Ads 

Searching

Installing a gem in fair enough but what if you don’t know what it’s called?

Well, one way of finding a gem is to look at the rubygems homepage at http://rubyforge.org/projects/rubygems/

However, this can be a bit overwhelming and may be a long way around if you know what you are looking for. In cases like these you can search a remote list of gems for the phrase you are after:

gem search mysql --remote gems.rubyforge.org

This will give a list of gems with the word ‘mysql’ in them.

Installing

Installing a particular gem is very simple:

sudo gem install mysql

That will, not unsurprisingly, install the gem ‘mysql’ (which is the ruby bindings for MySQL, not MySQL itself!).

The example above will give a choice of versions to install. On a Linux VPS simply choose the latest ‘ruby’ version. So at the time of writing I would select option (3) mysql 2.7 (ruby).

Often a gem will have several dependencies with it. To stop the install asking if you want the dependencies to be installed use this:

sudo gem install mysql --include-dependencies

Outdated

To get a list of gems that are now outdated (they have a newer version available), use this command:

gem outdated

Updating

To update all the installed rubygems is just as straightforward:

gem update

However, you may not want to update all at once, in which case specify the gem:

gem update mysql

Clean

This will remove outdated versions of gems that are installed, leaving the new updated version installed:

gem clean

This will leave a nice and shiny up to date rubygems install.

Removing

At some point you may want to get rid of a gem completely. No problem:

sudo gem uninstall mysql

Listing installed gems

To get a list of locally installed gems, issue this command:

gem list

That will give an overview of the gems you have installed.

Fabio Laganà Ruby on Rails, RubyGems , ,

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.