Fix Ruby gem install openssl/ssl.h error

Share this:

Getting the “fatal error: 'openssl/ssl.h' file not found” message? Here is a quick fix for the gem install openssl/ssl.h error.

I faced this problem when trying to install a gem that I am to use for work and had trouble trying to figure out how to get the installation process to find the ssl.h file that I knew was there on my Mac.

Ruby gem install fatal error: 'openssl/ssl.h' file not found

It turns out this issue is getting eventmachine to include the correct location of the openssl includes.

Fix the openssl/ssl.h file not found error

Firstly, I would recommend checking to make sure you have openssl installed on your Mac. You can use brew to install it.

brew install openssl

If it’s already installed, brew will give a warning that it is already installed. You could also search for it directly on the filesystem. If it’s installed, you will see the openssl directories in /usr/local/opt/ which are symlinks to their actual locations in brew’s /usr/local/Cellar/ directory.

ls -la /usr/local/opt/openssl*

Once you’ve confirmed that openssl is installed on your Mac, reinstall event machine using the following command. This should get eventmachine to now include the openssl includes and fix the gem install openssl/ssl.h error once and for all.

gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
Reinstall eventmachine to use /usr/local/opt/openssl/include

No more openssl.h error!

This time, the gem install should completely run without any error!

Ruby gem install now working fine

If this post has been useful, support me by buying me a latte or two 🙂
Buy Me A Coffee
Share this:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.