27

What is the difference between doing:

bundle exec rake

and

rake

I see people doing both, I never do bundle before my commands, curious what the reason for it is?

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
  • 2
    I think this http://stackoverflow.com/questions/6588674/what-does-bundle-exec-rake-dbmigrate-mean could have the answer – Khaled Dec 24 '12 at 21:13
  • Duplicate: http://stackoverflow.com/questions/6588674/what-does-bundle-exec-rake-mean – Max Nanasy May 13 '13 at 20:02

2 Answers2

22

bundle exec executes a command in the context of the bundle. This command executes the command, making all gems specified in the Gemfile available to require in Ruby programs. Very useful when you have many applications with different versions of gems used in them.

Please see docs for more information: http://gembundler.com/man/bundle-exec.1.html

Chetan Gawai
  • 2,361
  • 1
  • 25
  • 36
Tolik Kukul
  • 1,996
  • 16
  • 26
15

bundle exec runs the command after it in the environment of Bundler. So say you had rake 0.9 in you Gemfile, but rake 10 installed in RubyGems.bundle exec rake will run rake 0.9 instead of rake 10.

weddingcakes
  • 653
  • 1
  • 7
  • 14