8

I am using Ruby Enterprise Edition for my project. When I check all my rake task by run the command rake -T , I got the following error message:

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

The error message implies that I can use bundle exec to solve the problem, but I am not sure how? So, how to get rid of this error message?

------------------------------ more ---------------------------

I prefer to update my Gemfile instead of run bundle exec rake -T. But when I open my project Gemfile, I did not see rake 0.9.2 in my Gemfile, why the error message complains that I have it? Where could be the place I defined rake 0.9.2??

Mellon
  • 37,586
  • 78
  • 186
  • 264

2 Answers2

7

Run bundle exec rake -T, this ensures that the version of rake that is specified in your Gemfile is running, not another version.

Alternatively, update your Gemfile.

harald
  • 5,976
  • 1
  • 24
  • 41
  • I prefer to update my Gemfile, but I dont have rake 0.9.2 in my Gemfile, why the error message complain that I have it? Where could be the place I defined rake 0.9.2?? – Mellon Nov 08 '11 at 12:29
  • 7
    Mellon, check your Gemfile.lock. You probably updated rake after running `bundle install`. Run `bundle update rake` to update the Gemfile.lock. – harald Nov 08 '11 at 12:37
  • Harald, Thanks, it now works. Could you also please explain to me why rake is not defined in my Gemfile but in Gemfile.lock? Isn't it a gem? – Mellon Nov 08 '11 at 12:40
  • 1
    Mellon, Gemfile describes the immediate dependencies your project depends on. Gemfile.lock records the actual versions of those dependencies and all dependencies of those again. This is to allow `bundle install` to recreate your exact environment so you don't get any unpleasant surprises when deploying your app. – harald Nov 08 '11 at 12:45
0

This is because your rake tool does not match the version written in the Gemfile.

You first need to run this command, to ensure rake 0.9.2 get installed:

bundle install

Then, you can run rake 0.9.2 with the following command:

bundle exec rake -T

The bundle thing is a nice tool to help you manage the dependency of your application. You can get more info from here.

Santa Zhang
  • 884
  • 8
  • 13