Skip to content

Instantly share code, notes, and snippets.

@tgaff
Last active January 23, 2020 19:24
Show Gist options
  • Save tgaff/74fae05e11c151fa778346fd43174fab to your computer and use it in GitHub Desktop.
Save tgaff/74fae05e11c151fa778346fd43174fab to your computer and use it in GitHub Desktop.
fix ruby ssl error after brew ssl updates

problem description

Ruby and Python stopped working after brew ssl update. You'll likely have to do this for all rubies.

Possible manifestations of the error in ruby:

LoadError: library not found for class Digest::SHA1 -- digest/sha1

Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)

In python/gcloud stuff:

ERROR: gcloud failed to load: 'module' object has no attribute 'sha256'

ERROR:root:code for hash sha1 was not found.

fixes

Make sure your ruby-build is up to date. It was changed to pull down it's own ssl rather than using homebrew's copy. That's what makes this solution work.

rm -fr /Users/travis/.gem/ruby/2.3.8/gems
rm -fr ~/.rubies/2.3.8
ruby-build 2.3.8 ~/.rubies/2.3.8

Then you can try bundling but mysql2 gem might bork on sql too. I installed that thusly:

gem install mysql2 -v '0.3.21' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

Obviously adjust versions and paths.

other details

Homebrew will output the following when updating ruby-build:

ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded. To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following to your ~/.bash_profile: export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" Note: this may interfere with building old versions of Ruby (e.g <2.4) that use OpenSSL <1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment