Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Rails use the correct version of Ruby?

I have Ruby 2.0 installed but Rails doesn't recognize it and tells me to upgrade to 1.9.3.

When I run:

rails console

I get:

Rails 4 prefers to run on Ruby 2.0.

You're running
  ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

Please upgrade to Ruby 1.9.3 or newer to continue.

This happens with all Rails commands. rails new, rails s, etc., however, I definitely have Ruby 2.0 installed:

ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]

It also doesn't seem to be a problem with an incorrect default version of Ruby:

rvm list

rvm rubies

ruby-1.9.3-p429 [ x86_64 ]
=* ruby-2.0.0-p195 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

I read somewhere that it might be a problem with my PATH variable:

printenv PATH
/Users/Aoeu/.rvm/gems/ruby-2.0.0-p195/bin:/Users/Aoeu/.rvm/gems/ruby-2.0.0- p195@global/bin:/Users/Aoeu/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/Aoeu/.rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin

My Ruby seems to be installed in the right place:

which ruby
/Users/Aoeu/.rvm/rubies/ruby-2.0.0-p195/bin/ruby

Can anyone help?

like image 380
user1943735 Avatar asked Feb 16 '23 03:02

user1943735


2 Answers

It looks like something got really messed up in your rvm configuration. In this thread, the OP solved it by uninstalling rvm and reinstalling everything from scratch.

Be sure to enable autolibs by running:

\curl -L https://get.rvm.io | bash -s stable --autolibs=homebrew --rails
like image 156
Ju Liu Avatar answered Feb 18 '23 18:02

Ju Liu


You need to tell your gem environment which version of Ruby to use. You can do this in the command line with:

rvm --default 2.0.0
like image 30
Oved D Avatar answered Feb 18 '23 17:02

Oved D