Please install Homebrew(official) on your mac.
brew install rbenv ruby-build
Although I heard that this way tends to yield(don't catch up with the newest version of ruby), it is simple.
Just execute below
This command will add
eval "$(rbenv init -)" to your
Please check it like this
If you can't find out the line
export PATH="$HOME/.rbenv/bin:$PATH" and
eval "$(rbenv init -)", please add it by yourself.
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"
After that, restart your terminal or reload your
.bash_profile with this command.
And you can check you could install
rbenv or not by this command
This command will return the version of
OK, now we can get the list of the versions of Ruby with below.
rbenv install -l
This time, I assume that we chose
2.5.0 as the target.
rbenv install 2.5.0
Many commands will be executed.
After they are finished, try this.
and you can get like this
* system 2.5.0
This indicates you have
Ruby 2.5.0 but you are using the pre-installed Ruby.
So, let's change to the target ruby with below
rbenv global 2.5.0
For now, your mac is ready to use the
Ruby 2.5.0, but I recommend you to check the status of your
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
This will indicate the install status of rbenv.