Install chruby and ruby-install
brew install ruby-install chruby
Modify zshrc for binary and auto switching
#Add the following to the ~/.bash_profile or ~/.zshrc file:
#To enable auto-switching of Rubies specified by .ruby-version files,
#add the following to ~/.bash_profile or ~/.zshrc:
Install latest Ruby
This will install ruby
ruby-install --update ruby
Now to link it add this to your ~/.zshrc file. Remember to change the home and version.
Start using Ruby in a project
Create a .ruby-version file in the root of your project and add the version you want to use.
chruby will now automatically switch to the version in the .ruby-version file when you enter the directory.
echo "ruby-3.2.2" > .ruby-version