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?

Daniel Kehoe
  • 10,952
  • 6
  • 63
  • 82
iang
  • 83
  • 1
  • 1
  • 3

8 Answers8

30

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

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

Andreas Baumgart
  • 2,647
  • 1
  • 25
  • 20
14

You want to use bundle exec:

bundle exec rake db:migrate

Or, if you're using Rails 4 binstubs:

./bin/rake db:migrate
sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • 1
    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? – David Kim Dec 23 '13 at 10:28
  • 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. – sethvargo Dec 24 '13 at 16:44
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
laertiades
  • 1,992
  • 2
  • 19
  • 26
  • 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 +1 – semiomant Feb 19 '14 at 17:19
0

You can run this command

bundle exec rake db:migrate
Sojan Jose
  • 3,168
  • 6
  • 33
  • 52
Dheer
  • 773
  • 1
  • 6
  • 16
0

bundle update rake fixed the issue for me.

ssedano
  • 8,322
  • 9
  • 60
  • 98
RC_02
  • 3,146
  • 1
  • 18
  • 20
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
Community
  • 1
  • 1
Gareth Fuller
  • 328
  • 2
  • 12
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!

fantaxy025025
  • 809
  • 8
  • 7
-1

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

chpr
  • 1