mysqlで libssl.1.1.dylib がないとエラーが出たときの対応

アイキャッチ

環境

  • rails
  • mysql-client
  • Homebrew

※ dylibの有無はバージョンによって違いがあるかもしれません。

エラー内容

自分の場合は以下の通り

Reason: tried: '/usr/local/opt/mysql-client/lib/libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file), '/usr/local/Cellar/mysql-client/8.0.29/lib/libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file) - /Users/tk/dev/rebake/rebake/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle

対応内容

  • opensslがなければinstall
    brew install openssl@1.1

  • libsslとlibcryptoへの参照がないので、/usr/local/libに追加
    ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/lib/
    ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/lib

軽ーーく説明

  • エラーの通り/usr/local/opt/mysql-client/lib/libssl.1.1.dylibが存在しなかった
  • ls -la /usr/local/opt/mysql-client/lib/ を実行すると確かにファイルがない
  • libsslとlibcryptoを実行できればOKなはずなので、brewでinstallしたopensslのlibsslとlibcryptを参照可能にする
  • /usr/local/lib../Cellar/path/to/dylibのpathを参照しているからそれにあわせたほうがいいかも

参考URL

https://pavcreations.com/dyld-library-not-loaded-libssl-1-1-dylib-fix-on-macos/

stmon19

遊びが一番 人生遊び 好きにまみれてます