This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Bundler Ruby Dependency Manager Cheat Sheet

A quick reference guide for Bundler in Ruby: bundle install, updating gems, Gemfile syntax, deployment modes, and local development.

· Published

Bundler manages an application's dependencies through its lifecycle for Ruby projects.

Common CLI Commands

bundle install          # Install all required gems
bundle install -j4      # Parallel installation using 4 workers
bundle update           # Update all gems to newest matching versions
bundle update rails     # Update only a specific gem
bundle outdated         # Audit outdated gems

bundle exec <command>   # Run command in context of the bundle
bundle show <gemname>   # Display gem installation directory
bundle info <gemname>   # Show gem metadata
bundle gem <my_gem>     # Scaffold new gem skeleton

Gemfile Syntax

Basic Declarations

source 'https://rubygems.org'

gem 'rails', '~> 7.1.0'
gem 'pg', '>= 1.5'
gem 'puma'

Git & GitHub References

# Direct GitHub repository
gem 'devise', github: 'heartcombo/devise'

# Specific git branch or tag
gem 'devise', github: 'heartcombo/devise', branch: 'main'
gem 'nokogiri', git: 'https://github.com/sparklemotion/nokogiri.git', tag: 'v1.16.0'

Dependency Groups

group :development, :test do
  gem 'rspec-rails'
  gem 'factory_bot_rails'
end

group :production do
  gem 'aws-sdk-s3'
end

Production Deployment

In CI/CD pipelines and servers, bundle with deployment flags to prevent modifying Gemfile.lock:

# Modern Bundler deployment
bundle config set --local deployment 'true'
bundle config set --local without 'development test'
bundle install

Local Gem Overrides

Point a gem to a local checkout directory for active development:

bundle config local.my_gem ~/Developer/Projects/my_gem

Related topics