Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my environment require I run bundle exec?

Whenever I run a rake command (i.e. rake routes) I get this error:

You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.

If I run bundle exec rake routes it works.

I want to be able to simply rake routes without having to run bundle exec rake routes.

I've looked at other questions with similar errors and tried the various solutions (like running bundle update) to no avail.

Also, in my gemfile I specified gem 'rake', '0.9.2'

Any suggestions?

like image 550
vich Avatar asked Nov 12 '11 17:11

vich


People also ask

Why do I have to bundle exec?

bundle exec allows us to run an executable script in the specific context of the project's bundle. Upon running the above command, bundle exec will run the executable script for rake version specified in project's Gemfile thus avoiding any conflicts with other versions of rake installed system-wide.

What does bundle exec mean?

bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile). rake db:migrate is the script where db is the namespace and migrate is the task name defined.

What does bundle exec rspec do?

Description. This command executes the command, making all gems specified in the Gemfile(5) available to require in Ruby programs. Essentially, if you would normally have run something like rspec spec/my_spec.

What does bundle command do?

The bundle exec command ensures that executable programs installed by Gems don't interfere with your app's requirements. For instance, if your app needs a specific version of rake but the default version of rake differs, bundle exec ensures that you can still run the specific rake version compatible with your app.


1 Answers

Try to execute:

gem list

You'll probably see a couple of version installed for rake. By the way, bundle exec is the right way of executing your code in the context of a Rails application. So, you can use an alias for typing less.

like image 142
lucapette Avatar answered Sep 22 '22 22:09

lucapette