Ralph David Abernathy
Ralph David Abernathy

Reputation: 5508

How to update Ruby with Homebrew?

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

Upvotes: 110

Views: 196845

Answers (6)

spickermann
spickermann

Reputation: 106832

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

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

Then follow the output about steps you have to do manually to finalize the installation, like adding brew's Ruby path to the PATH ENV.

$ rbenv install 3.4.1
$ rbenv global 3.4.1

Upvotes: 232

LHM
LHM

Reputation: 891

I followed @spickermann's instructions here, but I was still running into trouble with the Mac System Ruby install being primary (ruby -v did not show my newly installed global ruby). I solved it by executing three more steps:

  1. rbenv init
    
  2. Following the instructions which appeared in the console. For me, using .zshrc:

    # Load rbenv automatically by appending
    # the following to ~/.zshrc:
    eval "$(rbenv init - zsh)"
    

    Yours may be different if you use .bashrc or .bash_profile, instead of .zshrc - in all circumstances, you should be able to change the eval statment to

    eval "$(rbenv init -)"
    

    and have it work equivalently.

  3. Start a new terminal (or re-source your rc file). For me, using .zshrc:

    source ~/.zshrc
    

After following those steps, ruby -v showed the desired version of Ruby and not the system-installed version.


Upvotes: 9

Devesh.452
Devesh.452

Reputation: 911

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

Upvotes: -4

ltrainpr
ltrainpr

Reputation: 3463

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>

Upvotes: 15

ovisirius
ovisirius

Reputation: 97

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

Upvotes: 8

Gustavo Rubio
Gustavo Rubio

Reputation: 10747

brew upgrade ruby

Should pull latest version of the package and install it.

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

Upvotes: 113

Related Questions