Last Updated: February 25, 2016
· domon

Fix OpenSSL errors when installing Ruby gems in OSX 10.11 El Capitan

There are errors like the following when installing Ruby gems using OpenSSL in OSX 10.11:

mini_ssl.c:4:10: fatal error: 'openssl/bio.h' file not found
#include <openssl/bio.h>

Since OpenSSL is not included in OSX 10.11, we have to install OpenSSL manually. I have already installed it with Homebrew:

brew install openssl

There are many ways to fix the problem, the approach I decided to take is adding build flags to Bundler configuration.

For example, the following command tells Bundler that for the puma gem, I want to use the OpenSSL installation from Homebrew:

bundle config build.puma --with-cppflags=-I$(brew --prefix openssl)/include