Arief R Ramadhan
Arief R Ramadhan

Reputation: 234

Must prepend bundle exec to rake db:migrate

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?

Upvotes: 2

Views: 1254

Answers (4)

pyfork
pyfork

Reputation: 3955

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.

Upvotes: 2

Noman Ur Rehman
Noman Ur Rehman

Reputation: 6957

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.

Upvotes: 3

Dave Kinkead
Dave Kinkead

Reputation: 47

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.

Upvotes: 0

kajal ojha
kajal ojha

Reputation: 1278

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

bundle exec rake db:migrate

Upvotes: 0

Related Questions