LinuxCommandLibrary

bundle

Manage Ruby gem dependencies for a project

TLDR

Install all gems defined in the Gemfile expected in the working directory

$ bundle install
copy

Execute a command in the context of the current bundle
$ bundle exec [command] [arguments]
copy

Update all gems by the rules defined in the Gemfile and regenerate Gemfile.lock
$ bundle update
copy

Update one or more specific gem(s) defined in the Gemfile
$ bundle update [gem_name1] [gem_name2]
copy

Update one or more specific gems(s) defined in the Gemfile but only to the next patch version
$ bundle update --patch [gem_name1] [gem_name2]
copy

Update all gems within the given group in the Gemfile
$ bundle update --group [development]
copy

List installed gems in the Gemfile with newer versions available
$ bundle outdated
copy

Create a new gem skeleton
$ bundle gem [gem_name]
copy

SYNOPSIS

bundle [options] <command> [<args>]

PARAMETERS

-v, --verbose
    Enable verbose output

-q, --quiet
    Silence Bundler output

--version
    Display Bundler version

--help
    Show help information

--no-color
    Disable color output

--retry <number>
    Retry network requests

--path <path>
    Install gems to specific path

--without <groups>
    Exclude gem groups

--local
    Use local cached gems

--frozen
    Do not allow updating Gemfile.lock

DESCRIPTION

The bundle command, part of Ruby's Bundler tool, manages gem dependencies for Ruby projects. It ensures consistent environments across development, staging, and production by installing exact gem versions specified in a Gemfile. Bundler creates a Gemfile.lock file that locks dependencies, preventing version conflicts and "it works on my machine" issues.

Key workflows include creating a Gemfile to declare dependencies, running bundle install to fetch and install gems into a vendor cache, and using bundle exec to run commands in the bundled environment. It supports groups like :development or :test for conditional loading. Bundler handles transitive dependencies automatically and provides commands for updating, checking, and visualizing dependency graphs.

Essential for modern Ruby/Rails apps, it integrates with tools like Rake and Capistrano. On Linux, install via gem install bundler or package managers like apt (ruby-bundler).

CAVEATS

Requires Ruby and gem installed. Most subcommands need a Gemfile. Network access needed for remote gems. Can increase deployment bundle size.

COMMON SUBCOMMANDS

install: Install gems from Gemfile.
update: Update gems or specific ones.
exec: Run command in bundle context.
show: List installed gems.
viz: Generate dependency graph.

EXAMPLE USAGE

$ bundle init # Create Gemfile
$ echo 'gem rails' >> Gemfile
$ bundle install
$ bundle exec rails server

HISTORY

Created by Carl Lerche in 2009 as a gem. Version 1.0 released in 2010. Integrated into Ruby core as default bundler since Ruby 2.6 (2018). Maintained by engine yard and community.

SEE ALSO

gem(1), ruby(1), rake(1)

Copied to clipboard