So, to update to the latest version of rake, use the gem command along with the install verb and then rake as the gem being updated: sudo gem update rake This is an interactive command line environment so you'll be asked a few questions in order to update the gem.
bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile). rake db:migrate is the script where db is the namespace and migrate is the task name defined.
First, check to make sure that rake is mentioned in your Gemfile. If it's not, add it, and specify the version "you already activated".
Then, you'll need to tell bundle to update the rake version it's using for your app:
bundle update rake
It'll update your Gemfile.lock
for you.
Where you are currently using rake commands like
rake db:migrate
Use this instead:
bundle exec rake db:migrate
this will be the case until the latest version of rails and/or rake work well together.
I thank to Dobry Den, cheers dude. but little more I had to do. here is solution (works for me). I had added
gem 'rake','0.8.7'
on Gemfile, which was not there, but my new version of rails automatically install rake(0.9.0).
after I had delete rake0.9.0 by gem uninstall rake
and after doing bundle update rake
, I can create and migrate database.
Rake 0.9.0 breaks rails.
See here: Rake 0.9.0 'undefined method 'task' '
Use bundle exec rake
instead of rake
to run rake at the correct version.
Specify the version that you want in your Gemfile.
gem 'rake', '0.9.0'
then
bundle update rake
you need to use bundle exec to run your rake task
bundle exec rake db:migrate
Oh look, it's the future. For me, it was complaining I had rake 10.x installed when it wanted 0.9.5. Not quite sure, not familiar enough with Ruby to really dig into what happened to the recent version numbers, but what I did was:
gem uninstall rake
gem install rake -v 0.9.5
to force the system to install the version of rake that the app wanted (for me it was Octopress).
I had this problem (with another gem that was not rake) and I was able to fix it by
gem uninstall <complaining gem>
gem install <complaining gem>
bundle install
bundle update
Note that the keyword 'sudo' was not used (ie. sudo bundle install) as that may place your gem into directories where your rails app might not be searching in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With