0

This question seems to happen a lot (here, here, and here), but never with a successful answer.

I have ruby 2.5.0 installed correctly and have verified it with ruby -v. However, when I open a new Terminal tab, it defaults me back to ruby 2.3.3p222 for some reason. I have ruby '~> 2.5.0' in my gemfile, if it helps.

Does anyone know how this is happening?

Liz
  • 1,369
  • 2
  • 26
  • 61

3 Answers3

2

RVM can read the .ruby-version file on the root of your project folder.

echo 2.5.0 > .ruby-version

Open a new terminal and check the Ruby version.

vinibrsl
  • 6,563
  • 4
  • 31
  • 44
  • This worked perfectly! I'm still not sure why, but thank you! – Liz Aug 11 '18 at 20:03
  • This `.ruby-version` file is like a default place where some services and applications look for your target version. Google Cloud Platform, Heroku, RBenv, RVM and some other services use this file. – vinibrsl Aug 11 '18 at 21:00
0

A new tab opens a new shell, which re-reads your shell's initialization files. It doesn't start with the environment variables which happen to be set in the currently-active tab.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • So how do I get it to update the initialization files to show the correct version of Ruby? – Liz Aug 10 '18 at 21:27
  • Perhaps you have the two versions of Ruby installed in different directories, but one happens to be either absent from `PATH` or later in `PATH` than the older one. – Thomas Dickey Aug 10 '18 at 22:06
0

If you are using rbenv, you can set your global ruby by:

rbenv global 2.5.0

Pretty much the same thing for rvm:

rvm --default use 2.5.0
Flavio Wuensche
  • 9,460
  • 1
  • 57
  • 54