Apparently Ubuntu and its newer derivatives come with OpenSSL 3.0 and in this case Ruby versions earlier than 3.1 used OpenSSL 1.1
In this case, the safest option is to follow the user manual and manually compile OpenSSL 1.1.
It worked for me too with Pop!_OS and asdf
PS: I put the export inside my .zshrc
Install the dependencies:
sudo apt install build-essential checkinstall zlib1g-devDownload OpenSSL 1.1.1:
cd ~/Downloads
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
tar xf openssl-1.1.1n.tar.gzCompile it:
cd ~/Downloads/openssl-1.1.1n
./config --prefix=/opt/openssl-1.1.1n --openssldir=/opt/openssl-1.1.1n shared zlib
make
make test
sudo make installLink the system's certs to OpenSSL 1.1.1 directory:
sudo rm -rf /opt/openssl-1.1.1n/certs
sudo ln -s /etc/ssl/certs /opt/openssl-1.1.1nUse RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/openssl-1.1.1n before the command to install the ruby version:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/openssl-1.1.1n rbenv install 2.7.6If you want to make this permanent, add this line to you .bashrc or .zshrc file:
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl-1.1.1n/"Then you don't need to use RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/openssl-1.1.1n before the command anymore.