6

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
  • 614
  • 1
  • 10
  • 26

2 Answers2

16

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.

Caleb
  • 1,452
  • 15
  • 20
2

Try typing

bundle exec rake db:migrate

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

Peter Goldstein
  • 4,479
  • 2
  • 19
  • 17
  • 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/x86_64-darwin13.0.0/openssl.bundle` - plus a load of other file paths? - thanks for helping! – TomHill Dec 22 '14 at 22:51
  • 1
    Have you updated OpenSSL since you installed that Ruby? Looks like an OpenSSL linking failure to me. – Peter Goldstein Dec 22 '14 at 22:58
  • My OpenSSL is: `OpenSSL 0.9.8za 5 Jun 2014` - is that ok for executing rake? – TomHill Dec 23 '14 at 01:27
  • That's not really the question. Check this out - http://stackoverflow.com/questions/25492787/ruby-bundle-symbol-not-found-sslv2-client-method-loaderror . You need to rebuild your Ruby. – Peter Goldstein Dec 23 '14 at 01:37
  • 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 – TomHill Dec 23 '14 at 02:18
  • 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` - https://github.com/sstephenson/rbenv#rbenv-rehash - to pick up the updated rake shim. – Peter Goldstein Dec 23 '14 at 02:26
  • 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 – TomHill Dec 23 '14 at 04:21
  • `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. – Peter Goldstein Dec 23 '14 at 06:19
  • 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 :) – TomHill Dec 23 '14 at 06:52