Homebrew 升级后 PHP 不可用:dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib

20
今天我升级了Homebrew,这导致PHP版本(7.2-7.3)被删除。每当我尝试重新安装它们时,都会显示以下错误:

今天我升级了Homebrew,这导致PHP版本(7.2-7.3)被删除。每当我尝试重新安装它们时,都会显示以下错误:

dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib
Referenced from: /usr/local/opt/curl-openssl/bin/curl
Reason: image not found
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "php"
Download failed: https://www.php.net/distributions/php-7.3.9.tar.xz

有什么建议吗?

6个回答

49

好的,我通过安装这个库来解决了这个问题 brew install libpsl

然后重新安装php brew reinstall php@7.2 --build-from-source

对于php@7.3也是一样的操作

请注意,重新安装php会重置所有php配置


4
这真是救命稻草。谢谢。 - Zaid Haider
我运行了这两个命令并重新启动了终端,但对错误没有任何影响。 - Xitcod13
5
我在运行php 8.2时遇到了类似的问题,例如dyld[1180]: Library not loaded: /usr/local/opt/libtiff/lib/libtiff.5.dylib Referenced from: <4DFABB9B-E15B-37C3-A4E9-496D6D2ED71E> /usr/local/Cellar/gd/2.3.3_4/lib/libgd.3.dylib。我通过运行brew reinstall gd来解决了这个问题。 - undefined
太棒了!我不知道libpsl是什么,但这个方法确实起作用了。只是提醒一下,我收到了一个警告:警告:不支持从源代码构建!你需要自己解决问题。失败是预料之中的,所以请不要提出任何问题! - undefined

4
在将php迁移到OpenSSH 1.1之后,出现了一个bug。无需安装libpsl
这个问题已经通过pr-44048得到解决。您应该卸载libpsl并重新安装php
brew uninstall libpsl
brew reinstall php

2
我找到了各种答案,但基本上是因为我在安装NMAP后运行了一个愚蠢的命令来修复错误,导致我破坏了我的Cellar目录及其内部的所有权限。
为了解决这个问题,我重新安装了brew和与php相关的所有内容。这将修复任何权限和/或符号链接问题。有时候你只需要把一切都清空,重新开始。
这是我的具体错误:
dyld[32102]: Library not loaded: /opt/homebrew/opt/libtiff/lib/libtiff.5.dylib
  Referenced from: <SOME-0E3C-3E56-AEC8-LONG-ID> /opt/homebrew/Cellar/gd/2.3.3_4/lib/libgd.3.dylib
  Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file),
'/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file),
'/usr/local/lib/libtiff.5.dylib' (no such file), 
'/usr/lib/libtiff.5.dylib' (no such file, not in dyld cache), 
'/opt/homebrew/Cellar/libtiff/4.5.1/lib/libtiff.5.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libtiff/4.5.1/lib/libtiff.5.dylib' (no such file), 
'/opt/homebrew/Cellar/libtiff/4.5.1/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file, not in dyld cache)

这个错误在我使用php的任何时候都发生。甚至包括php -v
但在执行任何操作之前,尝试一下brew updatebrew upgrade,也许你会幸运地解决问题,而不必去删除所有的php版本并重新安装。但这是我修复这个错误所采取的步骤。
  1. rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
  2. 然后按照这里的说明进行操作:docs.brew.sh/Installation 安装brew。(因为它们会不时更改)
  3. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  4. 删除所有版本的php
  5. brew search php 查看是否还有剩余的php版本旁边有php@7.4 ✔的勾选标记,删除这些版本使用brew uninstall php@7.4
  6. 例如brew uninstall brew-php-switcher(如果你使用它)
  7. brew upgrade
  8. brew cleanup
  9. 然后重新安装你的php版本。例如brew install php@7.4
  10. 然后重新安装brew-php-switcher(如果你使用它,我喜欢它)brew install brew-php-switcher
  11. 完成后,运行brew-php-swticher 8.2 我喜欢这个工具!(或者用你需要的版本替换8.2,只需使用7.4或8.0等)

1
今天我遇到了完全相同的libtiff错误,但在我的情况下是在安装deno之后发生的。你的解决方案有效,谢谢! - undefined
1
太棒了!我不知道这个答案会不会立即被投票淘汰,还是会留下来!很高兴能帮到你! - undefined

2

我尝试删除Cellar文件夹并重新安装PHP,这对我起作用了。

rm -rf /Users/rafaelgomes/.composer/*
rm -rf /usr/local/Cellar/*
brew doctor ; brew update ; brew upgrade
brew install php

0
我也遇到了类似的问题。在参考这里这里的指示后,我解决了这个问题。
  1. 我重命名了文件。

    定位libtiff

在我的情况下,我发现文件位于这里 Cellar/libtiff/4.6.0/lib/libtiff.6.dylib

mv Cellar/libtiff/4.6.0/lib/libtiff.6.dylib Cellar/libtiff/4.6.0/lib/libtiff.5.dylib

然后我安装了gd,然后出现了这个错误 php -v
dyld[23974]: Library not loaded: /usr/local/opt/gd/lib/libgd.3.dylib Referenced from: /usr/local/Cellar/php/8.2.12_1/bin/php Reason: tried: '/usr/local/opt/gd/lib/libgd.3.dylib' (no such file), '/usr/local/lib/libgd.3.dylib' (no such file), '/usr/lib/libgd.3.dylib' (no such file) zsh: abort php -v
在将libtiff.5.dylib更改回libtiff.6.dylib之后,重新安装gd,如步骤1所述。这只是为了确保将来不会出现任何问题。
brew reinstall gd
这里enter image description here 现在当我执行php -v时,问题已经解决了。enter image description here 实际上,在执行brew upgrade后,我尝试使用wp plugin list才到达这里。

-1
我通过以下方式解决了这个问题。
brew uninstall libpsl
brew remove php
brew install libpsl
brew install php@8.0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接