Ruby’s bundler introduces a new command to add a gem to the Gemfile.

The bundle add command was introduced in v1.15 of bundler.

bundle add rspec

This will add the gem (rspec in this example) into the Gemfile and also run bundle install to install the gem.

Lots of other package managers like npm and yarn had the add command which would add the dependency to the package list and also install it. Now bundler has this too.

The add command optionally takes version (-v), group (-g) and source (-s) options.

References:

  1. Bundler Version 1.15 release notes
  2. bundle add command docs