As a reminder, I was very worried about installing ruby through rbenv.
Tools for switching and managing ruby versions
Next, I will post the installation procedure (Mac).
Open the terminal It is around the installation of Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Paste and run This will install Homebrew.
Once Homebrew is installed, then
$brew install rbenv
Enter the command.
Enter rbenv -v
to check the version of rbenv
Next, I will install ruby, but to check if there is a desired version
$ rbenv install -l
1.8.5-p52
1.8.5-p113
1.8.5-p114
1.8.5-p115
1.8.5-p231
(Omitted)
It will be displayed.
If the desired version is not in this, it may not be displayed if the version of rbenv is old.
Type $ brew upgrade rbenv ruby-build
to update.
If you have the desired Ruby, enter the following to install Ruby.
$ rbenv install (version of target ruby)
How to verify Ruby installation through rbenv
$rbenv version
(Target version) (set by /Users/(username)/.rbenv/version)
You can check the version by typing.
Although it is good to install ruby through rbenv
$ruby -v
(Numbers not the desired version)
It was displayed that it was different from the one shown in $ rbenv version
.
I found out after a lot of research It is a phenomenon caused by the fact that the referenced Ruby has not changed. Originally, Mac already has Ruby, and it refers to the existing Ruby. So, make sure to pass the path to refer to Ruby installed by rbenv.
You just have to go through the path, but what do you do?
Just write in ~ / .bash_profile
to refer to Ruby installed by rbenv
.Bash_profile
is a file that is executed at login.
$cd $vi ~/.bash_profile
Since there is .bash_profile
in the home directory, go to the home directory and go to the home directory
Open .bash_profile
with vi
and write the following
export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
After writing with vi
,
source ~/.bash_profile
Enter and restart to change the Ruby version and you're done.
Manage ruby version with rbenv What to do when the Ruby version does not switch! What is the difference between .bash_profile and .bashrc
Recommended Posts