ruby-on-rails-3 – 为什么在Bundler之外运行Guard是危险的?

当我运行捆绑exec后卫时,一切都是犹太洁食,但如果我试图守卫,我会得到这个:

WARNING: You are using Guard outside of Bundler, this is dangerous and could not work. Using `bundle exec guard` is safer.

为什么是这样?

最佳答案 来自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

我不确定是否有任何关于守卫的具体内容,但一般来说,通过bundle exec运行所有宝石的可执行文件是一个好习惯.也许他们只是决定警告开发人员,没有它可以运行警卫可能会造成麻烦(例如,如果你的系统和Gemfile中有不同版本的后卫).

点赞