Ruby Academy · Lesson

Installing and Using Gems

Discover how to install gems using gem install and include them in your projects.

Lesson 2 of 410 steps

Installing and Using Gems is a free Ruby Academy lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the Ruby Academy learning path, and your progress syncs across the web and the CoddyKit app. The Ruby Academy course includes 4 lessons in total.

Getting Started with Gems

Installing and Using Gems

Ruby gems allow developers to easily add functionality to their applications.

In this lesson, you will learn how to install and use gems in your Ruby projects.

Installing and Using Gems — illustration 1

Installing a Gem

Use the gem install command to install a gem.

gem install nokogiri

Requiring a Gem in Your Code

After installing a gem, you must require it in your Ruby script.

require 'nokogiri'
puts 'Nokogiri gem loaded successfully!'

Installing a Specific Version of a Gem

You can install a specific gem version by specifying it.

gem install rails -v 6.1.4

Uninstalling a Gem

To remove an installed gem, use:

gem uninstall nokogiri

Updating All Gems

To update all installed gems to the latest versions, run:

gem update

Checking a Gem’s Usage

To find out where a gem is installed and its details, use:

gem which nokogiri

Installing Gems Globally or Locally

By default, gems are installed globally. To install a gem for a specific user only, use:

gem install nokogiri --user-install

Congratulations!

You have learned how to install, use, and manage Ruby gems.

Next, you will explore how to manage gem dependencies with Bundler.

Installing and Using Gems — illustration 10
Free to start

Learn Ruby with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
29
Lessons
109

Frequently Asked Questions

Is the “Installing and Using Gems” lesson free?

Yes — any 3 lessons of the Ruby Academy learning path, including “Installing and Using Gems”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The Ruby Academy course includes 4 lessons in total.

What will I learn in “Installing and Using Gems”?

Discover how to install gems using gem install and include them in your projects. You practise Ruby Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ruby Academy?

No prior experience is required. Ruby Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “Installing and Using Gems” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ruby Academy lesson?

Yes. Every Ruby Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Are Gems?
  2. Installing and Using Gems
  3. Managing Dependencies with Bundler
  4. Creating Your Own Gem
← Back to Ruby Academy