Skip to content
Latchkey

Ruby openssl Extension Build Fails - Missing libssl in CI

Building Ruby itself or a gem that links OpenSSL fails because the OpenSSL development library and headers are not installed. The extension cannot compile without libssl-dev.

What this error means

A ruby-build install or a gem native build stops reporting the OpenSSL library could not be found, or that openssl/ssl.h is missing. The build needs the OpenSSL -dev package, not just the runtime library.

build output
checking for openssl/ssl.h... no
OpenSSL library could not be found. You might want to use
--with-openssl-dir=<dir> option to specify the prefix where OpenSSL
is installed.

Common causes

OpenSSL development files not installed

The base image has the OpenSSL runtime but not libssl-dev/openssl-devel, so the headers needed to compile against it are missing.

OpenSSL in a non-standard prefix

On macOS/Homebrew or custom builds, OpenSSL lives outside the default search path, so the build cannot find it without an explicit prefix.

How to fix it

Install the OpenSSL development package

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y libssl-dev
# Alpine
apk add --no-cache openssl-dev
# RHEL/Fedora
dnf install -y openssl-devel

Point the build at a custom OpenSSL prefix

When OpenSSL is in a non-default location, pass its directory.

Terminal
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)" \
  rbenv install 3.3.0

How to prevent it

  • Bake libssl-dev/openssl-devel into images that build Ruby or openssl-linked gems.
  • Pin the OpenSSL prefix when using a non-default install.
  • Prefer precompiled gems that bundle their crypto dependencies.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →