liveBook · Manning

Bundling

As explained in The Well-Grounded Rubyist, Fourth Edition

Bundler is a Ruby dependency manager that resolves and installs the exact gem versions specified for a project.

Bundling manages a Ruby project's dependencies by tracking the required gems and installing the versions the project expects, rather than treating each installation as an isolated command. section 1.4.4

$ gem install prawn

Start with a Gemfile that names the package source and the project dependency, such as colorize version 1.1.0. section 1.4.4

Running Bundler resolves dependencies, fetches the needed gems, and installs them together. A project declaring colorize 1.1.0 reports the requested gem and an additional dependency as installed. section 1.4.4

Bundling fits into ordinary Ruby package and application work:

  • Use gem for individual package installation; use Bundler when a project must describe and install its dependency set. section 1.4.4
  • Load an installed library with require, then run the project command through bundle exec ruby c2fio.rb. section 1.4.4
  • Use gem with a named version when selecting a particular installed library version, as with Prawn 2.2.0. section 1.4.4

How The Well-Grounded Rubyist, Fourth Edition covers it

How deep it goes
Explains dependency declaration, resolution, fetching, installation, and execution, but does not detail Bundler's internal resolver.
Examples
Uses a colorize Gemfile, bundled installation output, and a bundle exec Ruby command.
What it assumes
Assumes Ruby and basic gems familiarity while introducing package installation, requiring libraries, and Bundler's project role.
What you can do after
Operate/configure a Ruby project by declaring gems in a Gemfile and installing them through Bundler.
How it connects
Connects Gemfile dependencies with RubyGems, gems, require, and bundle exec.

Also explained in

Compare how 8 books explain bundling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Rubyist, Fourth Edition. The section links point to the parts of the book it draws on.