2

I don't know what's going on but when I created a new model and want to run rake db:migrate but it gives me this error:

rake aborted! Gem::LoadError: You have already activated rake 11.0.1, but your Gemfile requires rake 10.5.0. Prepending bundle exec to your command may solve this.

I believe I didn't do any updates with the gem. I tells me to prepend bundle exec before executing the rake but I just want to run rake db:migrate as I did before.

How to make my local system rake gem version to fit in with my rails rake gem version?

Arief R Ramadhan
  • 234
  • 3
  • 16
  • 3
    This generally happens when two different `rake` versions exists in our system. A good explanation found [here](http://stackoverflow.com/questions/8275885/use-bundle-exec-rake-or-just-rake) – Venkat Ch Mar 10 '16 at 08:30

4 Answers4

3

You can fix this rake version conflict by following these steps.

  1. Uninstall rake by using the command gem uninstall rake

  2. Install the specific rake version by using the command gem install rake --version 10.5.0

You can also update the rake version in your Gemfile to 11.0.1

Also, if you use rvm, make sure the rake version does not change when the gemsets are switched as you use different ruby versions.

Noman Ur Rehman
  • 6,707
  • 3
  • 24
  • 39
2

This happens because Rake 11.0.1 is available in your system but your Rails app is using Rake 10.5.0.

Your app uses gems specified in the Gemfile.lock file which was created by Bundler when you first ran bundle install.

Updating your gems fixes this. As per Bundler docs:

Run the command bundle update to update your gems.
Bundler will update the Gemfile.lock file for you.

pyfork
  • 3,747
  • 2
  • 21
  • 18
0

Try prefixing bundle exec before the rake db:migrate command.

bundle exec rake db:migrate
kajal ojha
  • 1,248
  • 8
  • 20
0

There is a conflict somewhere between your system gems and those in your gem file. It looks like your local system is using rake 11.0.1 but your version of rails is using 10.5.0.

There are two ways to fix this:

1) use bundle exec rake db:migrate. This will execute the rake task in the context of the gems specified in your gem file. (see http://bundler.io/man/bundle-exec.1.html)

2) update your system gems so that they match those specified in your gem file.

Of the two, 1) is the simpler option.