Installing Ruby <2.4 on a modern Ubuntu

I sometimes use Ubuntu 20.04 for work. Today I had to install Ruby 2.2.10 for a client project, which wasn’t able to compile from source.

Apparently, you need your system to have OpenSSL 1.0 and GCC 6 present - 20.04 ships per default with GCC 7 and OpenSSL 1.1.

echo "deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe" | sudo tee /etc/apt/sources.list
sudo apt update && sudo apt install libssl1.0-dev g++-6
CC=$(which gcc-6) rbenv install 2.2.10

Credits: