newbie: error message when 'rake -T'

2019-04-06 11:12发布

问题:

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??

回答1:

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.



回答2:

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.