Search code examples
ruby-on-railsruby-on-rails-4rubygemsrakebundler

Rails rake updating issue - Could not find rake-10.4.2 in any of the sources


I'm attempting (without much success) to run rake db:migrate on a rails project, however it returns:

Could not find rake-10.4.2 in any of the sources
Run bundle install to install missing gems.

I ran bundle install and worked fine - installed rake 10.4.2, however when I ran: rake --version (for some reason you can't do rake -v ???) and it shows: rake, version 0.9.6

I ran bundle update rake and returned my list of gems and then: Your bundle is updated!

Why isn't rake updating? Is there something I'm doing wrong (I'm new to rails btw - so this is probably really simple)

Any help is really appreciated


Solution

  • TL; DR: gem install rake -v '10.4.2'

    So, I had this problem myself. I wanted to know why rails s would work yesterday and not today.

    First I checked if I was in the correct directory, I was. Then I re-ran bundle install to make sure rake was getting installed. It was, and I was able to see it in my Gemfile.lock So I figured my gemset might be corrupt (I use RVM). rvm gemset empty then bundle install

    Still, whenever I ran rails s, I got this error. bin/rails s worked, as well as bundle exec rails s. But I don't want a prefix, I want rails to work (It works in other rails projects)

    Eventually I tried gem install rake and it worked! I recommend adding -v '10.4.2' to the command so that you get the correct rake version. Now when I which rake, I get the gemset for my project: "/Users/cm022291/.rvm/gems/ruby-2.2.1@project_gemset/bin/rake"

    and when I run rails s the server starts successfully.