openssl@1.1没用过? dyld:未加载库:/usr/local/opt/openssl/lib/libssl.1.0.0.dylib

openssl@1.1 not used? dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

在尝试通过 pyenv 安装 python 时,我遇到了令人沮丧的 openssl 动态 link 错误,即使我在几个月前通过自制软件安装和配置了 openssl@1.1:

$ pyenv install -v 3.8.2
pyenv: /Users/fire/.pyenv/versions/3.8.2 already exists
continue with installation? (y/N) y
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
/var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807114817.54648 ~/projects
Downloading Python-3.8.2.tar.xz...
-> https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/libssh2/lib/libssh2.1.dylib
  Reason: image not found
/usr/local/bin/python-build: line 355: 55387 Abort trap: 6           aria2c --allow-overwrite=true --no-conf=true -o "${out}" ${ARIA2_OPTS} "" 1>&4
error: failed to download Python-3.8.2.tar.xz

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

我仔细检查了 openssl@1.1 的所有路径,尝试通过自制软件等重新安装 pyenv,但到目前为止没有任何效果。

简而言之:检查库引用缺少的动态库,并确认你已经re-built他们 在更改 openssl 版本之后也是如此。
您可以通过使用 brew upgrade 进行版本升级或通过 brew reinstall.

重新安装有问题的软件包来重建

为什么? Homebrew 似乎不认为 libssh2openssl@1.1 的依赖项,因此不会像其他情况那样自动重建它。


调查调试过程:

绞尽脑汁,google,等了一个小时,我又看了一眼失败:

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/libssh2/lib/libssh2.1.dylib
  Reason: image not found

从那里,我注意到 libssh2 是引用失败的原因:

  Referenced from: /usr/local/opt/libssh2/lib/libssh2.1.dylib

心血来潮,查了一下自己安装的libssh2 homebrew的版本:

$ brew info libssh2
libssh2: stable 1.9.0 (bottled), HEAD
C library implementing the SSH2 protocol
https://libssh2.org/
/usr/local/Cellar/libssh2/1.8.0 (182 files, 798.7KB) *
  Poured from bottle on 2018-11-14 at 17:45:34
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libssh2.rb
License: BSD-3-Clause
==> Dependencies
Required: openssl@1.1 ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 38,765 (30 days), 110,674 (90 days), 607,725 (365 days)
install-on-request: 2,946 (30 days), 4,789 (90 days), 19,954 (365 days)
build-error: 0 (30 days)

啊,可能就是这样!这是在 2018!

时安装的
  Poured from bottle on 2018-11-14 at 17:45:34

一个 brew upgrade libssh2 之后,我们开始营业了

==> Upgrading 1 outdated package:
libssh2 1.8.0 -> 1.9.0_1
==> Upgrading libssh2 1.8.0 -> 1.9.0_1
==> Downloading https://homebrew.bintray.com/bottles/libssh2-1.9.0_1.mojave.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/327c56ad6a54894e5ef9aa3019d2444d32f1d0fba80925940100e517dd3109c9?response-content-disposition=attachment%3Bfilename%3D%22libssh2-1.9.0_1.mojave.bottle.tar.gz%22&Policy
######################################################################## 100.0%
==> Pouring libssh2-1.9.0_1.mojave.bottle.tar.gz
  /usr/local/Cellar/libssh2/1.9.0_1: 184 files, 942KB
Removing: /usr/local/Cellar/libssh2/1.8.0... (182 files, 798.7KB)

...

然后,我们最初的问题就解决了:

$ pyenv install -v 3.8.2
pyenv: /Users/fire/.pyenv/versions/3.8.2 already exists
continue with installation? (y/N) y
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
/var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807115352.60918 ~/projects
Downloading Python-3.8.2.tar.xz...
-> https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz

08/07 11:53:54 [NOTICE] Downloading 1 item(s)
[#25162c 0B/0B CN:1 DL:0B]

08/07 11:53:55 [NOTICE] Allocating disk space. Use --file-allocation=none to disable it. See --file-allocation option in man page for more details.
[#25162c 9.0MiB/17MiB(52%) CN:1 DL:9.8MiB]

08/07 11:53:56 [NOTICE] Download complete: /private/var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807115352.60918/Python-3.8.2.tar.xz

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
25162c|OK  |   9.9MiB/s|/private/var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807115352.60918/Python-3.8.2.tar.xz

Status Legend:
(OK):download completed.
/var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807115352.60918/Python-3.8.2 /var/folders/c3/cmbbfq710rvdh4l82q2h_86ds4cblh/T/python-build.20200807115352.60918 ~/projects
Installing Python-3.8.2...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
checking build system type... x86_64-apple-darwin18.7.0

...

我今天遇到了同样的问题,但就我而言,libssh2 已经 up-to-date。

对我有用的是重新安装 libssh2:

brew reinstall libssh2