Search code examples
rubyrbenv

Why are Ruby versions conflicting when launching Rails server?


I am using rbenv on OS X. When I run ruby -v, I get "ruby 2.0.0p195" but when I launch rails s I get:

Gemfile syntax error:
/myapp/Gemfile:14: syntax error, unexpected ':', expecting $end
gem "mysql2", group: :mysql

It seems that the Gemfile is processed using Ruby 1.8.7. Why is it so?


Solution

  • You don’t have Rails installed in your rbenv Ruby installation, so it’s falling back to the rails system binary which is hardcoded to use the system Ruby. Simply gem install rails while using your rbenv Ruby installation.