bundlerでmysql2のインストールが失敗する

bundle updateしたらエラーが出た。

linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

ライブラリのリンクに失敗してるらしい。ld: library not found for -lsslと言われるのでOpenSSLのライブラリが見つからないのだろう。stackoverflowにそれっぽい質問と回答が見つかる。

mysql - Error when trying to install app with mysql2 gem - Stack Overflow

$ brew install openssl 
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

xcode-select --install という回答もあるが、自分の場合すでにインストール済みだった。

githubの方にも回答がある。これでも良さげ

`ld: library not found for -lssl` after Mac OS Sierra upgrade · Issue #795 · brianmario/mysql2 · GitHub

$ brew install openssl
$ export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

2019年7月ごろ追記)最近また動かなくなっていた。mkmf.logには

clang: error: unsupported option '--with-cppflags=-I/usr/local/opt/openssl/include'

と書かれていたので、.bundle/config ファイルから上記のオプションを取り除くとインストールできた