Skip to content

Ruby Environments

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:
source /opt/homebrew/opt/chruby/share/chruby/

#To enable auto-switching of Rubies specified by .ruby-version files,
#add the following to ~/.bash_profile or ~/.zshrc:
source /opt/homebrew/opt/chruby/share/chruby/

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.

export PATH="/Users/<home>/.rubies/ruby-<version>/bin:$PATH"

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

Install bundler

gem install bundler

Install gems

bundle install