Use bundle exec rake or just rake?

bundle exec executes a command in the context of your bundle.

That means it uses the gems specified in your Gemfile. Much of the time, running bundle exec rake foo has the same results as if you just ran rake foo, especially if you have the same gems installed systemwide as in your Gemfile. However, some applications may specify different versions of gems than the ones you have installed systemwide, and may want those exact gems and versions to be able to run correctly. If you just run without bundle exec, you may get some weird errors.

Using bundle exec guarantees that the program is run with the environment specified in the gemfile, which hopefully means it is the environment that the creators of the program want it to be run in, which hopefully means it should run correctly no matter what weird setup you have on your computer.

It basically standardizes the environment under which the program is run. This helps avoid version hell and makes life much easier.

See http://bundler.io/v1.3/man/bundle-exec.1.html for more info.

Leave a Comment