Reputation: 9314
When I run bundle exec guard
everything is kosher, but if I try to run guard
I get this:
WARNING: You are using Guard outside of Bundler, this is dangerous and could not work. Using `bundle exec guard` is safer.
Why is this?
Upvotes: 4
Views: 1511
Reputation: 47648
From bundler
official site:
Run an executable that comes with a gem in your bundle
$ bundle exec rspec spec/models
In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.
However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine. If you want a way to get a shortcut to gems in your bundle
$ bundle install --binstubs $ bin/rspec spec/models
The executables installed into bin are scoped to the bundle and will always work
I'm not sure whether there is anything specific about guard
, but in general it's a good practice to run all your gems' executables via bundle exec
. May be they just decided to warn developers that running guard
without it might cause troubles (e.g. if you have different versions of guard
in your system and in Gemfile
).
Upvotes: 2