Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active December 8, 2021 02:47
Show Gist options
  • Save havenwood/ba31f67c1d89ac236400 to your computer and use it in GitHub Desktop.
Save havenwood/ba31f67c1d89ac236400 to your computer and use it in GitHub Desktop.
Install the latest Homebrew precompiled Ruby with the chruby Ruby version switcher.
# Install Homebrew if you haven't already:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install the latest stable Ruby and chruby:
brew install ruby chruby
# Symlink brew Ruby to ~/.rubies where chruby will autodetect it:
mkdir -p "$HOME/.rubies"
ln -s "$(brew --prefix ruby)" "$HOME/.rubies/ruby-$(brew ls --versions ruby | cut -d" " -f2)"
# Add the following to your ~/.bashrc or ~/.zshrc file
# and run them once in your terminal or reload your terminal:
source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
# Switch to brew Ruby:
chruby ruby
# Switch to system Ruby:
chruby system
# Optionally set a default Ruby:
echo "ruby-3" > "$HOME/.ruby-version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment