Following up on my Guard tutorial, I explain here how to setup Guard to run
bundle install automatically everytime you modify your
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.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
Install the Gem
To install the
guard-bundler gem, add it to your
group :development do gem 'guard-bundler', require: false end
Gemfile should now look like this:
source 'https://rubygems.org' group :development do gem 'guard', require: false gem 'guard-bundler', require: false end [...more gems...]
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
guard :bundler do watch('Gemfile') end
This section tells Guard to run
bundle install everytime you modify Gemfile.
To test the new guard rule, run Guard:
Guard is watching your
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!