How to update Ruby with Homebrew?

RubyMacosHomebrew

Ruby Problem Overview


I want to know how to update to the latest stable version of Ruby with Homebrew. I am not interested in using RVM. Thanks.

Ruby Solutions


Solution 1 - Ruby

I would use ruby-build with rbenv. The following lines install Ruby 3.1.2 and set it as your default Ruby version:

$ brew update
$ brew install ruby-build
$ brew install rbenv

$ rbenv install 3.1.2
$ rbenv global 3.1.2

Solution 2 - Ruby

brew upgrade ruby

Should pull latest version of the package and install it.

brew update updates brew itself, not packages (formulas they call it)

Solution 3 - Ruby

To upgrade Ruby with rbenv: Per the rbenv README

  • Update first: brew upgrade rbenv ruby-build
  • See list of Ruby versions: versions available: rbenv install -l
  • Install: rbenv install <selected version>

Solution 4 - Ruby

Adding to the selected answer (as I haven't enough rep to add comment), one way to see the list of available versions (from ref) try:

$ rbenv install -l

Solution 5 - Ruby

open terminal

\curl -sSL https://get.rvm.io | bash -s stable

restart terminal then

rvm install ruby-2.4.2

check ruby version it should be 2.4.2

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRalph David AbernathyView Question on Stackoverflow
Solution 1 - RubyspickermannView Answer on Stackoverflow
Solution 2 - RubyGustavo RubioView Answer on Stackoverflow
Solution 3 - RubyltrainprView Answer on Stackoverflow
Solution 4 - RubyovisiriusView Answer on Stackoverflow
Solution 5 - RubyDeveshView Answer on Stackoverflow