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're experiencing timeouts when installing Ruby gems on macOS, the issue may be related to IPv6 connectivity. Disabling IPv6 has been reported as an effective solution. Here's how you can do it:
Open Terminal: You can find it in
Applications > Utilities > Terminal
.List All Network Services: Run the following command to see all network services on your system:
This will display a list of network services, such as Wi-Fi, Ethernet, etc.
Disable IPv6: For each network service, disable IPv6 by running:
sudo networksetup -setv6off "SERVICE_NAME"
Replace
"SERVICE_NAME"
with the name of the network service, e.g.,"Wi-Fi"
or"Ethernet"
. If the service name contains spaces, ensure you enclose it in quotes.Re-enable IPv6 (Optional): If you wish to re-enable IPv6 later, use:
sudo networksetup -setv6automatic "SERVICE_NAME"
By disabling IPv6, your system will default to using IPv4, which can resolve timeout issues during gem installations. Remember to re-enable IPv6 if you encounter any network issues or require IPv6 connectivity in the future.