This is an update to my older post on how to install the latest Ruby on MacOS Monterey. This post has been updated to reflect instructions for MacOS Sonoma (MacOS 14, which should be getting released or was released in the fall of 2023), depending on when you are reading this.
Before you start
Before you start, make sure you have the Command Line Tools for Xcode downloaded, and installed before you attempt any of this
Before you copy/paste the following command, I highly recommend you verify that it’s the same command as listed on Homebrew’s website
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install rbenv and helpers
brew install rbenv ruby-build rbenv-gemset rbenv-vars rbenv init curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
If everything above goes well, you need to make sure you modify your .zshrc, or .bashrc, or whatever shell you prefer, to load rbenv on subsequent invocations.
Modify your shell startup script
I added this to the bottom of my .zshrc
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" eval "$(rbenv init -)"
Install the latest version of Ruby
Check what the latest version is at https://www.ruby-lang.org/en/, as of 8/13/2023 it was 3.2.2.
# Use the following line, if you're still using Monterey, but you do not need to do this with Sonoma Developer Beta 5. #OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.2.2 rbenv install 3.2.2 rbenv global 3.2.2
Confirm you are using the latest ruby, open a new shell
ruby -v ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23]
Now you can go to the directory of your project, and just run bundle install
cd work/luther.io bundle install bundle exec jekyll s --config _config.yml,_config_dev.yml
That’s it. Hope this post was helpful.