Skip to content

Instantly share code, notes, and snippets.

@gogvale
Created September 26, 2022 21:48
Show Gist options
  • Save gogvale/5f7704210a5836c865ff496d92d51fa4 to your computer and use it in GitHub Desktop.
Save gogvale/5f7704210a5836c865ff496d92d51fa4 to your computer and use it in GitHub Desktop.
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-dev

Download 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.gz

Compile 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 install

Link 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.1n

Use 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.6

If 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.

Font: rbenv/ruby-build#1940 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment