To install multiple versions of Ruby, you can use a version manager such as
chruby. (though, chruby often failed compilation of ruby on my M2 MacBook)
Here are the steps to install and use
rbenv to manage multiple Ruby versions:
rbenv and the
ruby-build plugin using Homebrew:
brew install rbenv ruby-build
rbenv initialization commands to your shell configuration file (e.g.
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
Restart your terminal to apply the changes.
rbenv install command to install the desired Ruby versions:
rbenv install 3.2.0 rbenv install 2.6.6
rbenv global command to set the default Ruby version:
rbenv global 2.7.2
rbenv local command to set the Ruby version for a specific project:
cd myproject rbenv local 2.6.6
To switch between Ruby versions, use the
rbenv global command to set the desired version as the default, or use the
rbenv local command to set the version for a specific project.
Alternatively, you can also use
chruby to manage multiple Ruby versions. The steps to install and use
chruby are similar to those for
I hope this helps. Let me know if you have any questions or need further assistance.