M1 MAC smells good
Prerequisites: Install macports by referring to Installing MACPort on Mac Arm
- Install Rbenv and Ruby-build
sudo port install rbenv ruby-build
Copy the code
- Configuring environment Variables
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.profile
source ~/.profile
Copy the code
- Lists the available Rubies
rbenv install --list
Copy the code
- Install Ruby, and here I’m using the latest 2.7.2
Rbenv install 2.7.2Copy the code
You may encounter the following error and need to specify openSSL
Last 10 log lines:
"_write$UNIX2003", referenced from:
_conn_write in bss_conn.o
_conn_puts in bss_conn.o
_dgram_write in bss_dgram.o
_fd_write in bss_fd.o
_sock_write in bss_sock.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libcrypto.dylib] Error 1
make: *** [all] Error 2
Copy the code
And then you can fit Ruby again
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/local --with-gdbm-dir=/opt/local"2.7.2 rbenv install - vCopy the code
- Switch version
Rbenv Global 2.7.2 Rbenv Shell 2.7.2Copy the code
Check the version.
rbenv versions
Copy the code