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

14,198

Solution 1

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.

Solution 2

Try typing

bundle exec rake db:migrate

That will ensure that the Rake being invoked is the one you've bundled.

Share:
14,198
TomHill
Author by

TomHill

Updated on June 05, 2022

Comments

  • TomHill
    TomHill almost 2 years

    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

  • TomHill
    TomHill over 9 years
    hmmm - I'm getting an error: rake aborted! LoadError: dlopen(/Users/TomHill/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2‌​.0.0/x86_64-darwin13‌​.0.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method Referenced from: /Users/TomHill/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x8‌​6_64-darwin13.0.0/op‌​enssl.bundle - plus a load of other file paths? - thanks for helping!
  • Peter Goldstein
    Peter Goldstein over 9 years
    Have you updated OpenSSL since you installed that Ruby? Looks like an OpenSSL linking failure to me.
  • TomHill
    TomHill over 9 years
    My OpenSSL is: OpenSSL 0.9.8za 5 Jun 2014 - is that ok for executing rake?
  • Peter Goldstein
    Peter Goldstein over 9 years
    That's not really the question. Check this out - stackoverflow.com/questions/25492787/… . You need to rebuild your Ruby.
  • TomHill
    TomHill over 9 years
    Thanks for the suggestion - ran rbenv install 2.0.0-p247 - then rake db:migrate and again, - Could not find rake-10.4.2 in any of the sources, so tried brew install ruby - and again nothing. rake --version still shows 0.9.6. bundle exec rake db:migrate still shows: LoadError: dlopen - thanks so much for your help with this btw
  • Peter Goldstein
    Peter Goldstein over 9 years
    Running rake db:migrate is not going to work, per my answer. You have (or had) two separate problems. Assuming you've fixed the OpenSSL problem by reinstalling (and rebuilding) Ruby, then run bundle exec rake db:migrate. That will invoke the correct Rake. You should also probably run rbenv rehash - github.com/sstephenson/rbenv#rbenv-rehash - to pick up the updated rake shim.
  • TomHill
    TomHill over 9 years
    Sorry peter - maybe I didn't make myself clear - I tried both rake db:migrate as well as bundle exec rake db:migrate - neither of which worked... :( - but thanks anyway
  • Peter Goldstein
    Peter Goldstein over 9 years
    brew install ruby won't do anything for the Ruby VM, since you're using rbenv. You need to rebuild the Ruby. Try rbenv install 2.0.0-p598, set that as your Ruby, run gem install bundler and then do bundle.
  • TomHill
    TomHill over 9 years
    Thanks peter - I don't know what happened but it decided to start working once I installed ruby 2.1.0 via rvm - who knows whats going on - thank you for your continued assistance :)