Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

Solution 1:

Newer versions of OSX deprecated openSSL, leaving many dependencies broken. You need to reinstall ruby, but specify exactly where your openSSL libraries are. If you're using rvm then that looks like:

rvm reinstall 2.3.0 --with-openssl-dir=/usr/local/opt/openssl

If you're using homebrew, then a quick shortcut to where your libraries are is:

brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=`brew --prefix openssl`

Solution 2:

Method 1 (Install OpenSSL)

Type all these commands in your Terminal (OSX) just to be extra sure you've done everything:

rvm get stable
brew update
brew doctor
brew install openssl
rvm install ruby-2.4 (or whatever version)
rvm use ruby-2.4 (or whatever version)
rvm gemset create jekyll
gem install jekyll

Finally, you need OpenSSL installed before you compile Ruby before you install Jekyll (or other gems)!

Method 2 (Reinstalling Ruby)

Newer versions of OSX deprecated openSSL.

You need to reinstall Ruby!

RVM with OpenSSL

rvm reinstall 2.3.0 --with-openssl-dir=/usr/local/opt/openssl

With the latest RVM version

rvm get stable
rvm reinstall ruby-2.3.0

homebrew and OpenSSL

brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=`brew --prefix openssl`

Solution 3:

You just need to set this env variables so your compiler has the correct path for openssl libs (if using Homebrew on macOS, try brew info openssl to see this info):

$ export LDFLAGS=-L/usr/local/opt/openssl/lib
$ export CPPFLAGS=-I/usr/local/opt/openssl/include
# For pkg-config to find this software you may need to set:
$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

Then reinstall your ruby (rvm reinstall ruby-version)