Gem::LoadError: Rake?

2020-07-17 14:53发布

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

6条回答
时光不老,我们不散
2楼-- · 2020-07-17 15:27

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.

查看更多
smile是对你的礼貌
3楼-- · 2020-07-17 15:32

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

查看更多
Ridiculous、
4楼-- · 2020-07-17 15:35

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.

查看更多
smile是对你的礼貌
5楼-- · 2020-07-17 15:41

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.

查看更多
相关推荐>>
6楼-- · 2020-07-17 15:45

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
查看更多
SAY GOODBYE
7楼-- · 2020-07-17 15:46

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

查看更多
登录 后发表回答