First thing first: Never use sudo to install gems
Install the rbenv (https://github.com/rbenv/rbenv#readme) using homebrew (https://brew.sh/)
- Install rbenv:
brew install rbenv - Install ruby 3.1.6:
rbenv install 3.1.6 - Set ruby version globally:
rbenv global 3.1.6 - Open your shell initialization file :
vi ~/.zshrc - Ensure that you have the following line at the end of the file (for zsh):
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi - Save the file and then reload your shell configuration:
source ~/.zshrc - Perform step 4 and see if ruby version is updated
For more help use: rbenv –help. Using the help you can set the global or shell specific ruby version.
Cheers and Peace Out!!!