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

I have Ruby 2.0 installed, but Rails does not 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 installed Ruby 2.0:

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

This is also not a problem with the wrong version of Ruby by default:

 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 this could 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?

+4
source share
2 answers

It seems like something really messed up in your rvm configuration. In this thread, OP solved it by removing 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 
+6
source

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

 rvm --default 2.0.0 
+2
source

Source: https://habr.com/ru/post/1487730/


All Articles