Intern Track Roadmap

Bundler & Gemfile

This course explains how Bundler manages the gems a Rails app depends on. It covers how the Gemfile declares gems with constraints such as ~> and >=, and how groups limit gems to certain environments. It shows how Bundler resolves every constraint at once and records the exact versions in Gemfile.lock. It explains what bundle install does when the lock matches and when the Gemfile changes. It also covers why bin/rails loads locked versions through bundler/setup and when plain Ruby scripts need bundle exec.

What you'll learn

  • ✓How the ~> and >= constraints in a Gemfile limit which versions Bundler may pick
  • ✓How Gemfile groups restrict gems to specific environments
  • ✓What the four sections of Gemfile.lock record and why the file is committed to Git
  • ✓What bundle install and bundle check do when the lock matches or the Gemfile changes
  • ✓Why bin/rails never needs bundle exec and when other scripts do
  • ✓How to inspect installed and locked gems with gem list and bundle info
Free preview · Lesson 1 2 min read

What Bundler does

The Rails CLI: rails new course ended its setup lesson with this: "Gemfile and Gemfile.lock already exist when bin/setup runs bundle install. The lock file records the exact resolved gem versions. How that works, and how to manage gems on purpose, is for Bundler & Gemfile." This is that course.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...