Install RVM in macOS (step by step)
Actually, I am waiting for my workmate. He chatted back after I just start a blog. Sorry man, but I canโt stop writing ๐
Prerequisites
- Homebrew ๐บ
Letโs go!
1. Install GnuPG
$ brew install gnupg
2. Install GPG keys (pick First way or Second way)
2.1 First way
$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
2.2 Second way
$ gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
3. Install RVM
$ \curl -sSL https://get.rvm.io | bash
4. We will receive a thank you ๐ message in the console.
5. Quit all Terminal
6. Lunch a new Terminal and try this
$ rvm list
7. We will get this message
# No rvm rubies installed yet. Try 'rvm help install'.
8. Install some ruby version such as 2.7.1
- for an old version, such as 2.3.1 please check Tip topic below ๐
- for version 3+, please check Remark for Ruby version 3+ topic below ๐
$ rvm install 2.7.1
9. After installation, check which ruby version available.
$ rvm listruby-2.7.1 [ x86_64 ]# Default ruby not set. Try 'rvm alias create default <ruby>'.
10. Create default ruby version
$ rvm alias create default 2.7.1
11. Thatโs it! Enjoys ๐
Tip ๐ก
For the ruby old version, you may get this below error which relates openssl
/Users/pagorn/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
So, we should install openssl
from rvm
, then install old ruby with this openssl
$ rvm pkg install openssl
$ rvm install 2.3.1 --with-openssl-dir=$HOME/.rvm/usr
Remark for Ruby version 3+
When install ruby v3, we may specific openssl location.
Check your openssl location before installation
- location A
$ ls /usr/local/opt | grep openssl
openssl
openssl@1.1
openssl@3
openssl@3.1
$ rvm install ruby-3.1.0 --with-openssl-dir=/usr/local/opt/openssl@3.1
- location B
$ ls /opt/homebrew/opt | grep openssl
openssl
openssl@1.1
openssl@3
openssl@3.1
$ rvm install ruby-3.1.0 --with-openssl-dir=/opt/homebrew/opt/openssl@3.1