The problem with installing older Ruby versions, is that OpenSSL, a dependency of older Ruby versions, is "end of life" and not shipped using brew anymore. Later versions of OpenSSL are not compatible.
The only way to install older Ruby versions now, is to patch OpenSSL locally.
It's very important, that you make sure, that the whole dependency chain has been installed using the same Terminal. That means, if you install homebrew via a Rosetta Terminal, and then openssl/Ruby using an arm64 Terminal, then you need to completely uninstall everything, and start over. This guide has been tested with an arm64 Terminal. Make sure to NOT start the Terminal using Rosetta.
If you find packages like Ruby in
/usr/ (Intel), but brew and openssl in
/opt/ (arm64), then reinstall it using the Terminal you installed it with.
Start a Rosetta Terminal to deinstall everything from
/usr/ and start an arm64 Terminal to delete everything from
- delete Ruby
- delete openssl
- delete Homebrew
- install Homebrew
Make sure, that everything is now installed in
- To easily download the file, open the article you're reading in Safari
- Right click this link and select "Download Linked File As"
- Save as "firstname.lastname@example.org" in "Downloads"
- In Terminal, run:
brew install ~/Downloadsemail@example.com install this patched OpenSSL 1.0 version
- Run the following in Terminal to add openssl to your PATH.
echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc
- Add the following exports to your
# OpenSSL export PATH="/email@example.com/bin:$PATH" # For compilers to find firstname.lastname@example.org you may need to set: export LDFLAGS="-Lemail@example.com/lib" export CPPFLAGS="-Ifirstname.lastname@example.org/include" export RUBY_CFLAGS="-DUSE_FFI_CLOSURE_ALLOC"
- Reload your shell, in Terminal run:
- Verify your OpenSSL version:
openssl version OpenSSL 1.0.2u 20 Dec 2019
- Install Ruby using your preferred method, f.e.:
RUBY_CONFIGURE_OPTSemail@example.com ruby-build 2.3.8 ~/.runtimes/Ruby23x
This guide should help you to install the Core of OpenSSL 1.0 and Ruby 2x.
If you found this article helpful, please consider sharing it on Twitter and Reddit. It genuinely helps people to unblock themselves and might safe someone a day of frustration.