Bundler (Ruby)

Bundler is Ruby's dependency manager. It reads a Gemfile listing the gems your project needs, resolves compatible versions, and locks them in Gemfile.lock so every machine installs exactly the same set.

Ruby

You declare dependencies in a Gemfile (gem "rails", "~> 7.0"), then run bundle install. Bundler works out a set of gem versions that satisfy all the constraints, installs them, and records the exact resolved versions in Gemfile.lock. Committing that lockfile guarantees reproducible installs across developers and servers.

Running your app with bundle exec ensures it uses precisely the gems and versions Bundler resolved, avoiding conflicts with other gems installed system-wide. bundle update re-resolves to newer versions when you want them.

Bundler is to Ruby what npm is to Node or pip+requirements.txt is to Python. Together with RubyGems, it's the standard way every modern Ruby and Rails project manages dependencies.

Syntax

# Gemfile
source "https://rubygems.org"
gem "sinatra", "~> 3.0"
# then: bundle install

Examples

Ruby — bundle install reads this and writes Gemfile.lock with exact versions.

# Gemfile
source "https://rubygems.org"
gem "rails", "~> 7.1"
gem "rspec", group: :test

Learn it in a lesson

See also

Back to the Dictionary