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 1Common 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-devPin a version with a precompiled gem where available
- Check whether your eventmachine version ships a precompiled platform gem.
- If so, lock the Linux platform so the compile is skipped.
- 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
Ruby bcrypt Gem Build Fails - Missing Compiler in CIFix the bcrypt gem "Failed to build gem native extension" in CI - bcrypt has no external library dependency,…
Ruby sqlite3 Gem Build Fails - Missing libsqlite3 in CIFix the sqlite3 gem "sqlite3.h is missing" / "cannot find -lsqlite3" build failure in CI - install libsqlite3…
Ruby Gem Build "RbConfig" CFLAGS/Toolchain Mismatch in CIFix native gem builds failing from an RbConfig CFLAGS/compiler mismatch in CI - a Ruby built with one compile…