Thuta Learning
AdvancedProgrammingbeginner

RubyGems & Bundler

Relax. We'll talk through this in plain words — no textbook voice.

RubyGems is the package manager used to install Ruby libraries and packages. Bundler keeps the gems a project needs organized and consistent through a Gemfile.

ruby
# Install a gem globally
# gem install colorize

# Gemfile
source "https://rubygems.org"

gem "colorize"

# Install project dependencies
# bundle install

Gemfile is where you list the gems your project needs. bundle install installs those gems and records their exact versions in Gemfile.lock.

You should see
Bundle complete!

Info

On team projects, checking Gemfile and Gemfile.lock into version control keeps everyone's dependency versions in sync.

Easy traps

  • Installing a gem doesn't automatically make it usable in your code. You still need to add require "gem_name" wherever you need it.