user3399101
user3399101

Reputation: 1537

Gem::LoadError: Rake?

I'm trying to run rake db:migrate locally but I'm getting the below error:

Gem::LoadError: You have already activated rake 10.2.2, but your Gemfile requires rake 10.1.1. Using bundle exec may solve this.

Not sure why this is happening? It came out of no where.

Any idea how to resolve this?

Cheers

Upvotes: 4

Views: 7932

Answers (6)

philoye
philoye

Reputation: 2590

I didn't/don't specify gem 'rake' in my Gemfile, so I simply ran bundle update rake which correctly updated Gemfile.lock.

Upvotes: 0

guyaloni
guyaloni

Reputation: 5922

I think that updating all Gemfile.lock is dangerous, especially when you have many gems without a specific versions. Sometimes when you update a gem some behaviour is changed and it is really annoying to find why it happened.

For myself, I had the same problem and the solution was to modify Gemfile:

gem 'rake', "~> 10.2.2"

to

gem 'rake', "~> 11.1.2"

and then run

bundle update rake

Upvotes: 0

Dmitry J
Dmitry J

Reputation: 146

You can delete your Gemfile.lock. Then run bundle install and bundler will recreate updated Gemfile.lock with correct rake.

I just did that and this worked for me.

Upvotes: 13

Anshul Goyal
Anshul Goyal

Reputation: 77093

Try running bundle exec rake db:migrate and see if that works for you.

You seem to have multiple versions of rake installed. Do gem list to identify if that is the case.

Depending on that, you may want to uninstall one version using gem uninstall rake.

Upvotes: 1

MaxCarabou
MaxCarabou

Reputation: 25

None of these worked for me but I found a fix. In the application folder you are making (where you find app bin ect..) Open your "Gemfile.lock" find "rake 10.1.1"(just use find or search), change it to 10.2.2, save then rake. Good luck

Upvotes: 0

Renato Zannon
Renato Zannon

Reputation: 30021

Do as it says. Call rake as

bundle exec rake

Or, alterantively, run bundler like this:

bundle install --binstubs

And then:

bin/rake

This is happening because there're different versions of rake installed on your system, and it is loading the wrong one by default.

Upvotes: 4

Related Questions