Skip to content
Latchkey

Ruby eventmachine Gem Build Fails - Missing OpenSSL/C++ in CI

The eventmachine gem builds a C++ extension and optionally links against OpenSSL. The build fails when a C++ compiler is missing, or when OpenSSL headers are absent on the runner.

What this error means

bundle install fails installing eventmachine with a C++ compile error, a missing openssl/ssl.h, or a link failure. EventMachine’s extension needs g++ and (for TLS support) the OpenSSL development files.

gem output
Installing eventmachine 1.2.7 with native extensions
ERROR: Failed to build gem native extension.

ssl.cpp:18:10: fatal error: openssl/ssl.h: No such file or directory
make: *** [Makefile:245: ssl.o] Error 1

Common causes

No C++ compiler on the runner

EventMachine compiles C++ sources, so it needs g++/clang++, not just a C compiler. A slim image without the C++ toolchain fails the build.

OpenSSL development headers missing

When EventMachine links against OpenSSL for TLS, it needs openssl/ssl.h and libssl. Without libssl-dev the compile aborts on the missing header.

How to fix it

Install the C++ toolchain and OpenSSL headers

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y build-essential libssl-dev
# Alpine
apk add --no-cache build-base openssl-dev

Pin a version with a precompiled gem where available

  1. Check whether your eventmachine version ships a precompiled platform gem.
  2. If so, lock the Linux platform so the compile is skipped.
  3. Otherwise ensure g++ and libssl-dev are present before bundle install.

How to prevent it

  • Bake build-essential and libssl-dev into images that build eventmachine.
  • Use a full base image with the C++ toolchain for native gems.
  • Cache the bundle so the compile runs only when the gem changes.

Related guides

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