rake db:migrate doesn't work after ruby 2.2.2

2019-04-26 18:19发布

问题:

I recently upgraded from Ruby 2.2.2 to 2.2.3 using RVM. This messed up some things in my development environment but I could handle it so far thanks to useful error messages.

Now I wanted to add some migrations to my DB and encountered this error:

$ rake db:migrate
/Users/howard/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval': /Users/howard/.rvm/rubies/ruby-2.2.3/bin/rake:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
exec "$bindir/ruby" -x "$0" "$@"
                        ^
    from /Users/howard/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'

Any help is very appreciated.

I thought RVM prevents stuff like this from happening?

I use the latest versions of OS X, Ruby and Rails.

Thanks a lot in advance!

回答1:

I had the same issue today and resolved it with the following commands:

rvm uninstall 2.2.3

rvm install 2.2.3

rvm use 2.2.3 --default

gem install bundler

bundle install

You may also want to select a gemset before you run the last two with:

rvm gemset create your_gemset_name

rvm use 2.2.3@your_gemset_name

For whatever reason, the reinstall seemed to fix everything