TL;DR
If you find installing Ruby on your MacBook with Silicon Chip difficult, you’re not alone. However, there is a work around that works with me. I tested it on M2 Pro and M2 Air.
The How-to
If you don’t have openssl 1.1
export optflags="-w"
# Installing Ruby 2.5.3 - Dont worry if this step fails
arch -arm64 rvm install 2.5.3
# Installing openSSL
brew install openssl@1.1
Export all the environment variables
export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
Disable autolibs
rvm autolibs disable
Export Ruby flags
export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
export optflags="-Wno-error=implicit-function-declaration"
Install ruby x.x.x with openssl 1.1
replace x.x.x can be any version you would like to install. For example 3.0.0
rvm install x.x.x --with-openssl-dir=$(brew --prefix openssl@1.1)