127

I'm trying to run rails project, I get

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

If I do: "bundle install"

but I'm getting

You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7

while doing

rake db:migrate

9 Answers 9

249

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.

3
  • 2
    this didn't work for me. when i run this command it does exactly the same thing as 'bundle install' and it show that it is using the same rake version. It doesn't update it.
    – E.E.33
    Nov 1, 2011 at 16:09
  • 5
    I had to add gem 'rake', 'version #' to my gemfile, and run 'bundle update rake' for my gemfile.lock to be updated correctly. FYI for anyone that couldn't get this solution to work for them.
    – E.E.33
    Nov 1, 2011 at 16:22
  • 1
    I mean this may work, but is it a good idea to just add it as dependency (as opposed to leaving it as an implicit dependency) just for the sake of getting rid of an error? The real question is where is the other activated version coming from and what can you to enforce it to use the version in the Gemfile.lock (I don't have rake as a dependency in my Gemfile`)
    – mfaani
    Dec 29, 2020 at 18:11
45

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.

1
  • 3
    The bit about "the latest version of rails and/or rake" working well together only has meaning at a specific, unnamed, point in time, and under some specific assumptions about the work flow in use. I think this implication is "you're using a bleeding edge rails, and rake hasn't caught up yet." But that case can be solved by either the "bundle exec" or the "edit Gemfile" approaches as well, and these approaches also solve the problem when there are no intrinsic compatibility issues, but only a muddled workflow history.
    – jackr
    Jul 12, 2012 at 18:13
25

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.

8

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.

7

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
1
  • Seems not to "un-activate" the later version. Removing Rake entirely and re-installing works, though.
    – JosephK
    Feb 4, 2020 at 9:05
6

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).

2
  • 2
    The future called, and it wants to borrow your Hammer pants. Mar 7, 2013 at 4:27
  • Hi, it's the future again. I hear Hammer pants are finally making a comeback.
    – subdigit
    Jan 12, 2018 at 16:41
5

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.

4

Add this to your Gemfile

# Rake 0.9.0 break Rails.
gem "rake", "!= 0.9.0"

And then uninstall rake-0.9.0

3

If I understand what you're not asking, you need to open your Gemfile file and change the line...

gem 'rake', '0.8.7'

...to...

gem 'rake', '0.9.0'
3
  • What if I want to use 0.8.7 instead of 0.9?
    – Kir
    May 21, 2011 at 6:47
  • 7
    the rake gem isn't specified in your Gemfile by default since it's a Rails dependency. if you updated the rake gem to 0.9.0, you still have the 0.8.7 gem on your system (check with gem list). i'm pretty sure that if gem 'rake', '0.8.7' is still specified in your Gemfile.lock, it'll still use the 0.8.7 gem without a problem. if not, then try running bundle after adding gem 'rake', '~> 0.8.7' to your Gemfile (not .lock) and see if it says anything.
    – danneu
    May 21, 2011 at 6:55
  • gem 'rake' is not defined. It takes default one if I have multiple Gem Rake (0.8.7 and 0.9.0) . Can we make default to old one? May 25, 2011 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.