Installing Older Versions of Ruby
Introduction
Section titled “Introduction”Installing older versions of Ruby can sometimes be a necessity due to project dependencies. This guide outlines the steps for installing older versions of Ruby on Macs, both Intel and M1.
Warning: Older versions of Ruby may have security vulnerabilities as they might not receive timely updates.
Prerequisites
Section titled “Prerequisites”Make sure you have rbenv installed. If not, you can install it by following this guide.
Installing on Intel Macs
Section titled “Installing on Intel Macs”Ruby 2.x.x
Section titled “Ruby 2.x.x”Step 1: Try installing without any flags:
rbenv install 2.x.xIf unsuccessful, refer to the steps below specific to your Ruby version.
Ruby 2.6.6 and 2.6.10
Section titled “Ruby 2.6.6 and 2.6.10”Step 2: Run the following command:
RUBY_CFLAGS="-w" rbenv install 2.6.6Note: This method worked on an Intel Mac running Ventura (13.0.1) as of 3/27/23.
Installing on M1 Macs
Section titled “Installing on M1 Macs”Installing older versions of Ruby on M1 Macs can be a bit more challenging due to architectural differences and software compatibility issues. Here are the steps to install specific older versions of Ruby on M1 Macs.
General Installation
Section titled “General Installation”Step 1: As a starting point, try installing without any flags:
rbenv install 2.x.xIf this does not work, proceed to the more specific steps below tailored to each Ruby version.
Ruby 2.6.6 and 2.6.10
Section titled “Ruby 2.6.6 and 2.6.10”Step 2: Use the following command to bypass some of the compilation warnings:
RUBY_CFLAGS="-w" rbenv install 2.6.6Note: The above method is generally applicable for Ruby versions 2.6.x and may work for other versions as well.
Ruby 1.9.3
Section titled “Ruby 1.9.3”The default installation might fail due to a dependency on openssl@1.0.2, which is not supported on M1 Macs.
Step 3: Install with the latest OpenSSL (version 3 as of Nov 28, 2022) using the following command:
CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl)" rbenv install 1.9.3-p484Or if you have openssl@1.0 already installed, run:
CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 1.9.3-p484Warning: Using unsupported or outdated versions of OpenSSL may pose security risks. Proceed with caution.
By following these steps, you should be able to successfully install older versions of Ruby on M1 Macs. If you encounter any issues, consult the rbenv documentation or seek help from the community.
OpenSSL Considerations
Section titled “OpenSSL Considerations”Installing OpenSSL 1.0 on M1 Macs is not officially supported and should be performed cautiously.
Step 1: Download the custom OpenSSL formula:
curl https://raw.githubusercontent.com/rbenv/homebrew-tap/e472b7861b49cc082d1db0f66f265368da107589/Formula/openssl%401.0.rb -o openssl@1.0.rbStep 2: Install it:
brew install ./openssl@1.0.rbStep 3: Optionally, remove the formula file to clean up:
rm -rf ./openssl@1.0.rbBy following these guidelines, you can install older versions of Ruby safely and efficiently. Always remember to exercise caution when using outdated or unsupported software.