Ruby is a programming language , used generally for web development , through a ruby library called rails .
Under macOS , ruby comes pre-installed , and it can be found under : /System/Library/Frameworks/Ruby.framework/Versions/
. Starting macOS Catalina version 10.15 , this is deprecated , and future versions of macOS might not contain ruby by default .
Rbenv is a ruby version manager , which allows to select the ruby version to be active . It also allows to install multiple versions of ruby .
Rbenv installs under the current user directory : ~/.rbenv
, and the installed ruby versions , are installed , under : ~/.rbenv/versions
Mac 은 기본적으로 Ruby 를 가지고 있습니다. 하지만 오래된 버전이기 때문에 지금과 맞지 않는 부분이 많습니다. 일반적으로 Homebrew 를 사용해 Ruby 를 설치할 수 있지만, 설치한 Ruby 가 실행 되진 않습니다. 때문에 Rbenv 를 사용해 실제로 사용할 Ruby 버전을 지정해야 합니다.
- 본 글은 영어로 작성되어 있지만 순서대로 따라하면 문제 없습니다. 다만, Zsh, bash 확인이 필요합니다.
환경
- MacBook Pro(Intel Core)
- Monterey OS(Version 12.2.1)
- git version 2.32.0 (Apple Git-132)
First clone rbenv
using the following command :
1
| git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
Then execute
1
| cd ~/.rbenv && src/configure && make -C src
|
- If macOS before catalina , and using bash , execute :
1
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
- If macOS catalina and after , and using zsh , execute :
1
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
|
Execute
1
| ~/.rbenv/bin/rbenv init
|
Open Nano editor
and to autoload rbenv , add :
ctrl-x , to save and exit.
and to autoload rbenv , add :
1
| eval "$(rbenv init - zsh)"
|
Ctrl-x , to save and exit.
Execute
- If the default shell is bash . Usually , this is true for MacOS versions , prior to Catalina .
- If the default shell is zsh . Usually this is true , for MacOS Catalina , and after .
Install ruby build , to install ,versions of ruby
1
| mkdir -p "$(rbenv root)"/plugins
|
1
| git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
|
Verify rbenv has been installed correctly
1
| curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
|
Show the lastest stable releases
Install Ruby
1
| rbenv install <Version>
|
rbenv rehash
Version Check(rbenv)
Set global
Version check(Ruby)