mysql2:库未加载:自制软件更新后的/usr/local/opt/openssl/lib/libssl.1.0.0.dylib

Hir*_*103 6 openssl mysql2 macos-mojave

在我将 mac OS Mojave 从 升级v10.14.0v10.14.2以及所有使用 Homebrew 安装的软件包后,我在运行时开始收到以下错误bin/rails console

/Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.4/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /usr/local/opt/mysql@5.6/lib/libmysqlclient.18.dylib
  Reason: image not found - /Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.4/lib/mysql2/mysql2.bundle
Run Code Online (Sandbox Code Playgroud)

我尝试卸载mysql2gem 并使用 cpp 和 ld 标志安装它:

gem uninstall mysql2
gem install mysql2 -v 0.4.4 -- --with-cppflags=-I/usr/local/opt/openssl/include/openssl --with-ldflags=-L/usr/local/opt/openssl/lib
Run Code Online (Sandbox Code Playgroud)

但它没有帮助。

我也尝试升级mysql2到最新版本(v0.5.3在撰写本文时),但它也不起作用

ls -l /usr/local/opt/openssl/lib 给我:

total 14472
drwxr-xr-x  4 hirurg103  staff      128 Sep 10 16:13 engines-1.1
-r--r--r--  1 hirurg103  staff  2265596 Dec 13 19:06 libcrypto.1.1.dylib
-r--r--r--  1 hirurg103  staff  3930864 Sep 10 16:13 libcrypto.a
lrwxr-xr-x  1 hirurg103  staff       19 Sep 10 16:13 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--  1 hirurg103  staff   485860 Dec 13 19:06 libssl.1.1.dylib
-r--r--r--  1 hirurg103  staff   720400 Sep 10 16:13 libssl.a
lrwxr-xr-x  1 hirurg103  staff       16 Sep 10 16:13 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x  5 hirurg103  staff      160 Dec 13 19:06 pkgconfig
Run Code Online (Sandbox Code Playgroud)

我没有看到libssl.1.0.0.dylibmysql2抱怨

你以前遇到过这个错误吗?你能解决它吗?如何解决?

Hir*_*103 11

OpenSSL 1.0于 2019-12-31 停产

重新安装mysql2与宝石--with-cflags--with-ldflags指向参数openssl@1.1固定的错误:

gem uninstall mysql2
gem install mysql2 -v 0.4.4 -- --with-cflags=\"-I/usr/local/opt/openssl@1.1/include\" --with-ldflags=\"-L/usr/local/opt/openssl@1.1/lib\"

bundle install
Run Code Online (Sandbox Code Playgroud)


小智 5

对我来说最终的解决方案是:

brew update
brew upgrade
Run Code Online (Sandbox Code Playgroud)

在尝试这些命令之前,我也尝试brew reinstall openssl过几次。我还导出了 LIBRARY_PATH:export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/并且我通过 rbenv 重新安装了 ruby​​。

因此,如果 brew 更新和升级没有为您清除错误,请尝试重新安装 openssl。然后,如果这不起作用,请重新安装 ruby​​。