12
votes

I have Rake version 0.9.1 but I need to use 0.8.7 for a project, and I'm fairly certain I have both version installed but it always uses 0.9.1 by default. Is there a way to specify which version of Rake to use?

I'm trying to run this: rake db:drop db:create db:migrate db:seed and I get this error: You have already activated rake 0.9.1, but your Gemfile requires rake 0.8.7. Consider using bundle exec.

4
Well, the answer was in your question: Consider using bundle exec ;)Arsen7

4 Answers

25
votes

gem search (or list) rake, should tell you which versions are installed.

You can invoke rake with a specific version number bracketed with underscores.

$rake _0.7.3_

This is a standard feature of gem packaged binaries.

19
votes

You can specify the version of Rake to use, in your Gemfile:

gem 'rake', '0.8.7'

Though the "error" message you are getting says it all... you need to run:

bundle exec rake ...

... in order to use the right rake to run your rake tasks.

More info on bundle exec: http://gembundler.com/man/bundle-exec.1.html

8
votes

Try executing gem uninstall rake then just pick the version you want to uninstall.

3
votes

It happens because you are using rake from the system. (latest version by default) The solution is use follow command:

bundle exec rake db:migrate

Also, you can create alias. Because this command is too big and difficult to write.

echo "alias be='bundle exec'" >> ~/.bash_profile
source ~/.bash_profile

Then you can use follow short command:

be rake db:migrate