Ruby rake loaderror - bundle exec rake not working

2019-05-06 10:10发布

问题:

I'm trying to run the command rake db:migrate but I keep getting this error:

/Users/[name]/.rvm/gems/ruby-2.2.1/bin/rake:23:in `load': cannot load such file -- /Users/[name]/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/specifications/default/bin/rake (LoadError)
from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/rake:23:in `<main>'
from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

Trying bundle exec rake db:migrate also gives me the same error.

Is there a way I can solve this issue? (I'm on Mac OS X 10.10.5)

EDIT: The first letter of my [name] in the error is upper case even though in my system, it's lower case.

EDIT [PARTIALLY SOLVED]: So I was using Ruby version 2.2.1 and I was supposed to use 2.1.2. Although this did not fix the rake command error, I was trying to run rails server which successfully ran after changing my Ruby version.

回答1:

If none of the above mentioned comments worked for you, then I suspect you may need to update rake gem. Try:

bundle update rake

See if that fixes the issue. If not, let me know. I will update the answer.