You have already activated X, but your Gemfile requires Y

ming yeow picture ming yeow · Jun 11, 2011 · Viewed 61.6k times · Source

When running rake I get this error:

You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Consider using bundle exec.

Using bundle exec rake instead of just rake seems to work, but is it the best way to fix this?

Answer

matt picture matt · Jun 18, 2011

Using bundle exec is the right way to do this.

Basically what's happening is that you've updated rake to 0.9.2 which now conflicts with the version specified in your Gemfile. Previously the latest version of rake you had matched the version in your Gemfile, so you didn't get any warning when simply using rake.

Yehuda Katz (one of the original Bundler developers) explains it all in this blog post.

To avoid typing bundle exec ... all the time, you could set up an alias or function in your shell for commands you commonly use with Bundler. For example this is what I use for Rake:

$ type bake
bake is a function
bake () 
{ 
    bundle exec rake "$@"
}