Installing ruby gems

suggest change

This guide assumes you already have Ruby installed. If you’re using Ruby < 1.9 you’ll have to manually install RubyGems as it won’t be included natively.

To install a ruby gem, enter the command:

gem install [gemname]

If you are working on a project with a list of gem dependencies, then these will be listed in a file named Gemfile. To install a new gem in the project, add the following line of code in the Gemfile:

gem 'gemname'

This Gemfile is used by the Bundler gem to install dependencies your project requires, this does however mean that you’ll have to install Bundler first by running (if you haven’t already):

gem install bundler

Save the file, and then run the command:

bundle install

Specifying versions

The version number can be specified on the command live, with the -v flag, such as:

gem install gemname -v 3.14

When specifying version numbers in a Gemfile, you have several options available:


As a best practice: You might want to use one of the Ruby version management libraries like rbenv or rvm. Through these libraries, you can install different versions of Ruby runtimes and gems accordingly. So, when working in a project, this will be especially handy because most of the projects are coded against a known Ruby version.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents