Ruby 2.5.9 is an old version that does not officially support Apple Silicon (ARM architecture). Additionally, it depends on OpenSSL 1.1, which has been disabled in Homebrew since October 2024. This means that installing Ruby 2.5.9 on a Mac M1/M2 requires a manual installation of OpenSSL 1.1, since it’s no longer available via Homebrew.
This guide will walk you through installing Ruby 2.5.9 on an Apple Silicon Mac without using Rosetta, covering OpenSSL 1.1 installation, Ruby installation using asdf
, and general compatibility notes.
Ruby 2.5.9 requires OpenSSL 1.1, but Homebrew has disabled it due to security concerns. Since newer OpenSSL versions (such as 3.x) are not compatible with Ruby 2.5.9, we must manually download, compile, and install OpenSSL 1.1.
Since Homebrew no longer provides OpenSSL 1.1, you need to download it manually from the official website.
Downloading via curl
may not work due to SSL/TLS issues. Instead, download it directly from your browser:
🔗 Download OpenSSL 1.1.1w → https://www.openssl.org/source/openssl-1.1.1w.tar.gz
Move the downloaded file to your terminal’s working directory.
Run the following commands in the terminal:
tar -xvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
Now, compile and install OpenSSL 1.1:
./config --prefix=/opt/openssl-1.1
make -j$(sysctl -n hw.ncpu)
sudo make install
This will install OpenSSL 1.1 in /opt/openssl-1.1
.
To ensure Ruby uses the correct OpenSSL version, update your environment variables:
export PATH="/opt/openssl-1.1/bin:$PATH"
export LDFLAGS="-L/opt/openssl-1.1/lib"
export CPPFLAGS="-I/opt/openssl-1.1/include"
export PKG_CONFIG_PATH="/opt/openssl-1.1/lib/pkgconfig"
To make these changes permanent, add them to your ~/.zshrc
or ~/.zshenv
:
echo 'export PATH="/opt/openssl-1.1/bin:$PATH"' >> ~/.zshrc
echo 'export LDFLAGS="-L/opt/openssl-1.1/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/opt/openssl-1.1/include"' >> ~/.zshrc
echo 'export PKG_CONFIG_PATH="/opt/openssl-1.1/lib/pkgconfig"' >> ~/.zshrc
source ~/.zshrc
Each user may have their own preferred Ruby version manager. This tutorial demonstrates using asdf
, but you can adapt it to rbenv
or ruby-install
.
If you haven't installed asdf
, do it via Homebrew:
brew install asdf
Then, ensure asdf
is loaded:
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc
source ~/.zshrc
Now, install Ruby 2.5.9, ensuring it links to OpenSSL 1.1:
RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl-1.1" asdf install ruby 2.5.9
If you prefer rbenv, use:
brew install rbenv
eval "$(rbenv init -)"
RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl-1.1" rbenv install 2.5.9
rbenv global 2.5.9
After installing Ruby, check if the correct version is active:
ruby --version
It should output:
ruby 2.5.9p229 (2021-04-05 revision 67939) [arm64-darwin24]
To confirm OpenSSL is correctly linked:
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
Expected output:
OpenSSL 1.1.1w 11 Sep 2023
Since RubyGems versions newer than 3.3.x may not be fully compatible with Ruby 2.5.9, you need to downgrade RubyGems before installing Bundler.
Run the following command:
gem install rubygems-update -v 3.2.3
update_rubygems
This ensures that RubyGems works correctly with Ruby 2.5.9.
Now, install the Bundler version compatible with Ruby 2.5.9:
gem install bundler -v 2.3.26
If you get a timeout error, retry the installation.
✅ Now, Ruby 2.5.9 is installed on your Mac M1/M2 without Rosetta! 🎉
If you face any issues:
- Ensure OpenSSL 1.1 is correctly installed and referenced.
- Restart your terminal and re-run
source ~/.zshrc
if necessary. - If you still face dependency issues, consider using Docker or a newer Ruby version for better support.
This guide ensures a legacy-compatible Ruby 2.5.9 installation on Apple Silicon Macs while avoiding Rosetta.
Happy coding! 🚀
If you get this error trying to install gems:
Run this for the certificates
curl -o ~/cert.pem https://curl.se/ca/cacert.pem
and
export SSL_CERT_FILE=~/cert.pem
or
echo 'export SSL_CERT_FILE=~/cert.pem' >> ~/.zshrc