Credit to https://stackoverflow.com/questions/15511943/troubles-with-rvm-and-openssl
# rvm install <rub-version> --with-openssl-dir=$(brew --prefix openssl@<openssl-version>)
# e.g.
#
rvm install ruby-3.3.6 --with-openssl-dir=$(brew --prefix openssl@3)
First, check and see if you have openssl installed. You should see something like this:
$ brew --prefix openssl
/usr/local/opt/[email protected]
If openssl is not installed, do so.
$ brew install openssl
$ brew unlink openssl
$ brew link --force openssl
If you have more than one openssl installed, consider removing all but one to make your life easier.
$ brew cleanup openssl
$ brew list --versions openssl
$ brew uninstall <unwanted-openssl-version-here>
Now reinstall the ruby version, specifying the desired openssl path.
$ rvm reinstall <your-version-here> --with-openssl-dir=`brew --prefix openssl`
Finally, verify that your ruby was compiled with the same openssl it was linked to. If you see the same version twice, you should be all set.
$ ruby -ropenssl -e'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'
OpenSSL 1.1.1d 10 Sep 2019
OpenSSL 1.1.1d 10 Sep 2019
If later you install other versions of ruby, you will need to pass the same --with-openssl-dir argument. Alternatively, I believe you can set the following variables in your bash profile.
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix openssl)/lib/pkgconfig"
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix openssl)/lib"
If the above doesn't work, remove the lines from your bash profile and just use the --with-openssl-dir argument as above.