Cannot build ruby 2.5, 2.6, 2.7 and 3.0 on Ubuntu
Since Ubuntu 22.04, old Ruby versions like 2.5
, 2.6
, 2.7
and 3.0
cannot be compiled because they rely on OpenSSL 1.1
and it has been replaced by version 3
.
So, if you try to install those versions using rvm
, you’ll get an error that something is deprecated: Since OpenSSL 3.0
.
But we can build OpenSSL 1.1
and point rvm
to it.
First check if you have the build-essentials
package installed:
sudo apt install build-essential
Then download OpenSSL version 1.1.1w
, build it and install it locally:
cd ~/Downloads
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config --prefix=$HOME/.openssl/openssl-1.1.1w --openssldir=$HOME/.openssl/openssl-1.1.1w
make
make install
rm -rf ~/.openssl/openssl-1.1.1w/certs
ln -s /etc/ssl/certs ~/.openssl/openssl-1.1.1w/certs
cd ~
Now we can proceed and install Ruby (example with Ruby 3.0.4
):
rvm install ruby-3.0.4 --with-openssl-dir=$HOME/.openssl/openssl-1.1.1w