16

I am trying to update Ruby on my computer to version 2.7.0 as that is the latest stable version.

Running macOS Catalina Version 10.15.3

Have tried the top two solutions from this StackOverflow post.

1. Using just brew

brew upgrade ruby

just confirms that "ruby 2.6.5 already installed"

2. Using rbenv

rbenv install 2.7.0

rbenv global 2.7.0

After installation I get confirmation that ruby 2.7.0 is installed, but when I close terminal, and check version, 2.6.5 is still the current version.

Initially when I tried this, I got an error BUILD FAILED (OS X 10.15.3 using ruby-build 20200115). Based on advise in this github issue I found that Xcode was not installed (it was installed, but something removed it in the last few months). I re-installed it, but still got the same issue.

3. Also tried RVM based on answer 3 from this post.

rvm upgrade 2.7.0

But I am prompted if I want to use ruby-2.6.3 I did said yes by accident. So now I am back down to 2.6.3

Do I need to do something more to change the global environment settings for Ruby? It seemed that rbenv global 2.7.0 would do this.

Mr. J
  • 1,524
  • 2
  • 19
  • 42
  • 2
    I don't recommend brew's version or rbenv. (though many people swear by rbenv) If you remove both of those and have only RVM installed, then you can `rvm install 2.7.0` and then `rvm --default use 2.7.0` and it'll stick. – anothermh Feb 12 '20 at 06:29
  • How would I remove the brew version and the rbenv version? – Mr. J Feb 12 '20 at 06:32
  • 1
    `brew uninstall ruby` and https://stackoverflow.com/a/36840977/3784008 – anothermh Feb 12 '20 at 06:33
  • That worked, but I still need to type `rvm --default use 2.7.0` every time I start a new terminal. Is there a way to permanently make it default? – Mr. J Feb 13 '20 at 03:22
  • 1
    Run the `--default` command, then run `rvm list`, then exit your terminal and open it again, then run `rvm list` again. Paste the output of `rvm list` into your question for us to see both before and after. – anothermh Feb 13 '20 at 23:29

4 Answers4

27

As per advice from anothermh, uninstalled rbenv and brew versions of Ruby

Uninstallation

brew uninstall ruby for removing brew version

Use accepted answer on this SO article for removing rbenv

Install Ruby via RVM

Install RVM as per instructions || as per this

rvm install (ruby version)

rvm --default use (ruby version)

can use rvm list to see available ruby versions.

Dipak
  • 6,532
  • 8
  • 63
  • 87
Mr. J
  • 1,524
  • 2
  • 19
  • 42
2

If you have rbenv, run these commands in Terminal:

  1. rbenv install 3.0.1(or any other desired version number) to install the version you want.
  2. rbenv versions, to verify that the newly installed version is on the list.
  3. rbenv global to see which version is set to be your global version.
  4. rbenv global 3.0.1 to make this (i.e. 3.0.1) version global.
  5. rbenv global command to verify which is your global version, it should now be 3.0.1.
eva
  • 43
  • 5
1

You should avoid using Homebrew to update Ruby because it can create problems with the OS. A very complete and safe explanation I found is at this medium post https://ashley-tharp.medium.com/getting-started-with-ruby-on-macos-a4d78e633e11

It worked very well for me. I hope it helps!

galo hernandez
  • 163
  • 1
  • 3
0

I my case :

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

Then :

brew update

Finally :

rvm install 2.6.1
Ayoub EL ABOUSSI
  • 636
  • 6
  • 13