I’m pretty sure you had encounter some error while trying to install older versions of ruby with rvm. This snippet is useful if you encounter an error related to libssl-dev on Ubuntu.

Sometimes is not enough with installing the apt package libssl-dev.

So here is what we have to do to download openssl-1.1.1g manually and install it.

First install the build-essential package in case you don’t have it, it will be useful to compile the library.

$ sudo apt install build-essential

Now create a directory to keep the download and the source code while the installation.

$ mkdir tmp
$ cd tmp

Download and extract the code.

$ wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
$ tar zxvf openssl-1.1.1g.tar.gz

Enter the directory and configure the installation dir (~/.openssl).

$ cd openssl-1.1.1g
$ ./config --prefix=$HOME/.openssl/openssl-1.1.1g --openssldir=$HOME/.openssl/openssl-1.1.1g

Now that we have configured we have to run make and make test in order to check that everything is correct.

$ make
$ make test # you might get a few tests failing but just ignore it

And we can install openssl.

$ make install

We should delete the dir certs and link our operating system certs.

$ rm -rf ~/.openssl/openssl-1.1.1g/certs
$ ln -s /etc/ssl/certs ~/.openssl/openssl-1.1.1g/certs

Finally if you were having trouble installing a Ruby version with rvm you can try again targeting the openssl installation (-with-openssl-dir).

$ cd ~
# let us install older rubies now by using RVM. Hurray!
$ rvm install ruby-x.x.x --with-openssl-dir=$HOME/.openssl/openssl-1.1.1g # replace ruby-x.x.x with the version number you wish to install

That’s all. RVM should install the version without failing again.