rake db:migrate is being aborted due to rake version difference [duplicate]
Asked Answered
M

8

8

I am getting the error

rake db:migrate --trace
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
/Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:116:in `require'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:116:in `rescue in require'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:122:in `require'
/Users/iang/code/Projects/work/startco/config/boot.rb:4:in `<top (required)>'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/iang/code/Projects/work/startco/config/application.rb:1:in `<top (required)>'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/iang/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/iang/code/Projects/work/startco/Rakefile:4:in `<top (required)>'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:93:in `load_rakefile'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:77:in `block in run'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `load'
/Users/iang/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `<main>'

used bundle and it did not fix the problem... any ideas as to help fix this problem?

Morpheme answered 21/12, 2013 at 2:11 Comment(1)
skipped over the "exec" part, runing "bundle exec rake db:migrate" workedMorpheme
A
14

You want to use bundle exec:

bundle exec rake db:migrate

Or, if you're using Rails 4 binstubs:

./bin/rake db:migrate
Avigdor answered 21/12, 2013 at 4:22 Comment(2)
Could you help me understand the nature of the error message, though? On my rails applications, usually running the rake command works fine - but on a recent tutorial project, I ran into this issue and don't understand why (Rails 4.0.1, Ruby 2.0.0, Gem 2.0.3 running on Ubuntu 12.04). Did I unwittingly 'activate' a newer rake? (How do I do that?) and why does it confuse the interpreter/Gemfile?Percept
Sure. Gems have different versions (as you know). The Rails app is requesting Rake version x, but Rake version y is first in the load path. So Ruby can't activate the correct version. Bundler solves this.Avigdor
K
30

I hit the same error. Running bundle update solved it.

Update: As suggested by TuK bundle update rake is the way to go.

Knotgrass answered 24/12, 2013 at 15:10 Comment(3)
Yep - this solves the mismatched version error message. It's the right answer!Percept
Running bundle update may update more than desired. Running bundle update rake will only update rake.Dominate
Thx TuK, sounds reasonable.Knotgrass
A
14

You want to use bundle exec:

bundle exec rake db:migrate

Or, if you're using Rails 4 binstubs:

./bin/rake db:migrate
Avigdor answered 21/12, 2013 at 4:22 Comment(2)
Could you help me understand the nature of the error message, though? On my rails applications, usually running the rake command works fine - but on a recent tutorial project, I ran into this issue and don't understand why (Rails 4.0.1, Ruby 2.0.0, Gem 2.0.3 running on Ubuntu 12.04). Did I unwittingly 'activate' a newer rake? (How do I do that?) and why does it confuse the interpreter/Gemfile?Percept
Sure. Gems have different versions (as you know). The Rails app is requesting Rake version x, but Rake version y is first in the load path. So Ruby can't activate the correct version. Bundler solves this.Avigdor
H
4

I got this error message while deploying to production with capistrano. To fix it I executed the following on my production server:

gem update rake
Humanitarianism answered 27/12, 2013 at 23:58 Comment(1)
I used gem uninstall rake. You will be prompted for the version you want uninstall. that helped me to revert to 10.1.0. Anyway @Goodfellow's idea helped me to find this, so +1Ostrich
B
0

You can run this command

bundle exec rake db:migrate
Buskin answered 14/1, 2014 at 13:57 Comment(0)
C
0

bundle update rake fixed the issue for me.

Chiton answered 17/1, 2014 at 19:33 Comment(0)
I
0

I had the same error but running bundle update rake didn't work for me. This answer worked for me. You have to remove your Gemfile.lock:

rm Gemfile.lock

then re-bundle:

bundle install
Ixia answered 30/1, 2014 at 20:20 Comment(0)
G
0

I got the answer. Why we got this error? For the rake version of our OS is different from the version of our project. When we set the same. Everything gets ok!

The light way is set the same version in our Gemfile. And make sure keep all the project the same rake!

gem 'rake', '10.2.2' #forking error! force the version the same with our OS and all projects!!!

I hope U see what I said and the real reason of this error. Then we will have more resolutions such as "bundle update rake". Thanks!

Greta answered 13/4, 2014 at 15:17 Comment(0)
H
-1

just install old version by command: gem install rake -v '10.1.0'

Hydraulic answered 23/1, 2014 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.