Keith Bennett
Keith Bennett

Reputation: 4970

Install of Nokogiri on Mac fails on openssl build with Ruby 2.4

I just updated and reloaded rvm, rvm installed 2.4.0, and when I run gem I get:

➜  ~   gem install irbtools
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
➜

I Googled it, found several purported solutions, but didn’t find one that would work except for the suggestion to use the insecure gem URL, which I didn't want to do.

BTW, openssl is installed, but not by brew:

➜  ruby-2.4.0   brew install openssl
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version

How can I get gem to work with a secure gem source?

Upvotes: 0

Views: 465

Answers (1)

Keith Bennett
Keith Bennett

Reputation: 4970

The solution was to install brew's OpenSSL:

brew install --force openssl

(I got a strange message saying that `--force was ignored, but it did install ok.)

Then, do a brew info openssl and RTFM! :) Based on what it told me, I added this to my ~/.zshrc file:

# For Ruby 2.4 to find brew's OpenSSL: export LDFLAGS=-L/usr/local/opt/openssl/lib export CPPFLAGS=-I/usr/local/opt/openssl/include export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

Then, I opened a new terminal window and reinstalled Ruby 2.4:

rvm reinstall 2.4

After that, gem worked.

Upvotes: 1

Related Questions