问题
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?
回答1:
You want to use bundle exec
:
bundle exec rake db:migrate
Or, if you're using Rails 4 binstubs:
./bin/rake db:migrate
回答2:
I hit the same error. Running bundle update
solved it.
Update: As suggested by TuK bundle update rake
is the way to go.
回答3:
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
回答4:
bundle update rake
fixed the issue for me.
回答5:
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
回答6:
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!
回答7:
You can run this command
bundle exec rake db:migrate
回答8:
just install old version by command: gem install rake -v '10.1.0'
来源:https://stackoverflow.com/questions/20714689/rake-dbmigrate-is-being-aborted-due-to-rake-version-difference