Reputation: 5508
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
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
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:
rbenv init
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.
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
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
Reputation: 3463
To upgrade Ruby with rbenv: Per the rbenv README
brew upgrade rbenv ruby-build
rbenv install -l
rbenv install <selected version>
Upvotes: 15
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
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