Stefan Wille

Guard Bundler Tutorial - Run "bundle install" Automatically

August 2, 2015

Guard/Bundler Tutorial

Following up on my Guard tutorial, I explain here how to setup Guard to run bundle install automatically everytime you modify your Gemfile.

If you don't know Guard yet, please read my Guard tutorial first.


Working with a Gemfile can be annoying: edit the file, run bunde install, check for error messages, repeat. Or even forget to run bundle install and check in copies of Gemfile and Gemfile.lock that don't match into version control.

With Guard, you can avoid this. Setup like in this tutorial, it will run bundle install automatically for you.


Guard's support for Bundler comes as a separate gem, the guard-bundler gem.

Install the Gem

To install the guard-bundler gem, add it to your Gemfile:

group :development do
  gem 'guard-bundler', require: false

Your Gemfile should now look like this:

source ''

group :development do
  gem 'guard', require: false
  gem 'guard-bundler', require: false

[...more gems...]

Run bundle install to actually download and install the gem:

$ bundle install

Extend the Guardfile

Now that you have the gem, set it up in your Guardfile:

guard :bundler do

This section tells Guard to run bundle install everytime you modify Gemfile.

Test it

To test the new guard rule, run Guard:

$ guard

Guard is watching your Gemfile now.

Setup your terminal and editor in a way that you can see both at the same time. Save your Gemfile. Voilá! You see bundler running bundle install for you!