切换 php 版本后 libldap-2.4.2.dylib 未加载

Clo*_*ity 5 php macos homebrew

dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib当将 php 版本切换回8.0.

\n

我可以通过修复它brew reinstall php@8.0,但是当切换版本时它会再次发生。

\n

我使用的是 MacOS Big Sur 11.4,但 Mojave 也遇到了这个问题。

\n

我的流程

\n
$ php -v\nPHP 7.4.19 (cli) (built: May 29 2021 10:41:11) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans\n    with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies\n(base)\n\n$ brew install shivammathur/php/php@8.0\n\n$ php -v\nPHP 8.0.6 (cli) (built: May 14 2021 07:18:20) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v4.0.6, Copyright (c) Zend Technologies\n    with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies\n(base)\n\n$ brew unlink php && brew link --overwrite --force php@7.4\n\n$ php -v\nPHP 7.4.19 (cli) (built: May 29 2021 10:41:11) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans\n    with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies\n(base)\n\n$ brew unlink php && brew link --overwrite --force php@8.0\n\n$ php -v\ndyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib\n  Referenced from: /usr/local/bin/php\n  Reason: image not found\n[1]    91532 abort      php -v\n(base)\n
Run Code Online (Sandbox Code Playgroud)\n

包裹信息

\n
$ brew info php@7.4 php@8.0 openldap libiconv\nphp@7.4: stable 7.4.19 (bottled) [keg-only]\nGeneral-purpose scripting language\nhttps://www.php.net/\n/usr/local/Cellar/php@7.4/7.4.19 (494 files, 72.3MB)\n  Built from source on 2021-05-29 at 10:42:03\nFrom: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php@7.4.rb\nLicense: PHP-3.01\n==> Dependencies\nBuild: httpd \xe2\x9c\x94, pkg-config \xe2\x9c\x94\nRequired: apr \xe2\x9c\x94, apr-util \xe2\x9c\x94, argon2 \xe2\x9c\x94, aspell \xe2\x9c\x94, autoconf \xe2\x9c\x94, curl \xe2\x9c\x94, freetds \xe2\x9c\x94, gd \xe2\x9c\x94, gettext \xe2\x9c\x94, glib \xe2\x9c\x94, gmp \xe2\x9c\x94, icu4c \xe2\x9c\x94, krb5 \xe2\x9c\x94, libffi \xe2\x9c\x94, libpq \xe2\x9c\x94, libsodium \xe2\x9c\x94, libzip \xe2\x9c\x94, oniguruma \xe2\x9c\x94, openldap \xe2\x9c\x94, openssl@1.1 \xe2\x9c\x94, pcre2 \xe2\x9c\x94, sqlite \xe2\x9c\x94, tidy-html5 \xe2\x9c\x94, unixodbc \xe2\x9c\x94\n==> Caveats\nTo enable PHP in Apache add the following to httpd.conf and restart Apache:\n    LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so\n\n    <FilesMatch \\.php$>\n        SetHandler application/x-httpd-php\n    </FilesMatch>\n\nFinally, check DirectoryIndex includes index.php\n    DirectoryIndex index.php index.html\n\nThe php.ini and php-fpm.ini file can be found in:\n    /usr/local/etc/php/7.4/\n\nphp@7.4 is keg-only, which means it was not symlinked into /usr/local,\nbecause this is an alternate version of another formula.\n\n\nTo have launchd start php@7.4 now and restart at login:\n  brew services start php@7.4\nOr, if you don't want/need a background service you can just run:\n  php-fpm\n==> Analytics\ninstall: 34,679 (30 days), 89,314 (90 days), 165,001 (365 days)\ninstall-on-request: 34,481 (30 days), 88,821 (90 days), 164,225 (365 days)\nbuild-error: 0 (30 days)\n\nphp: stable 8.0.6 (bottled), HEAD\nGeneral-purpose scripting language\nhttps://www.php.net/\n/usr/local/Cellar/php/7.4.12 (495 files, 72.2MB)\n  Built from source\n/usr/local/Cellar/php@8.0/8.0 (494 files, 77.5MB) *\n  Built from source on 2021-04-09 at 09:59:53\n/usr/local/Cellar/php/8.0.6 (500 files, 77.8MB)\n  Poured from bottle on 2021-05-29 at 17:48:14\nFrom: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb\nLicense: PHP-3.01\n==> Dependencies\nBuild: httpd \xe2\x9c\x94, pkg-config \xe2\x9c\x94\nRequired: apr \xe2\x9c\x94, apr-util \xe2\x9c\x94, argon2 \xe2\x9c\x94, aspell \xe2\x9c\x94, autoconf \xe2\x9c\x94, curl \xe2\x9c\x94, freetds \xe2\x9c\x94, gd \xe2\x9c\x94, gettext \xe2\x9c\x94, glib \xe2\x9c\x94, gmp \xe2\x9c\x94, icu4c \xe2\x9c\x94, krb5 \xe2\x9c\x94, libffi \xe2\x9c\x94, libpq \xe2\x9c\x94, libsodium \xe2\x9c\x94, libzip \xe2\x9c\x94, oniguruma \xe2\x9c\x94, openldap \xe2\x9c\x94, openssl@1.1 \xe2\x9c\x94, pcre2 \xe2\x9c\x94, sqlite \xe2\x9c\x94, tidy-html5 \xe2\x9c\x94, unixodbc \xe2\x9c\x94\n==> Options\n--HEAD\n    Install HEAD version\n==> Caveats\nTo enable PHP in Apache add the following to httpd.conf and restart Apache:\n    LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so\n\n    <FilesMatch \\.php$>\n        SetHandler application/x-httpd-php\n    </FilesMatch>\n\nFinally, check DirectoryIndex includes index.php\n    DirectoryIndex index.php index.html\n\nThe php.ini and php-fpm.ini file can be found in:\n    /usr/local/etc/php/8.0/\n\nTo start php:\n  brew services start php\nOr, if you don't want/need a background service you can just run:\n  /usr/local/opt/php/sbin/php-fpm --nodaemonize\n==> Analytics\ninstall: 59,614 (30 days), 153,695 (90 days), 636,046 (365 days)\ninstall-on-request: 58,355 (30 days), 150,786 (90 days), 621,760 (365 days)\nbuild-error: 0 (30 days)\n\nopenldap: stable 2.5.4 (bottled) [keg-only]\nOpen source suite of directory software\nhttps://www.openldap.org/software/\n/usr/local/Cellar/openldap/2.5.4 (339 files, 7.0MB)\n  Poured from bottle on 2021-05-29 at 10:13:28\nFrom: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openldap.rb\nLicense: OLDAP-2.8\n==> Dependencies\nRequired: openssl@1.1 \xe2\x9c\x94\n==> Caveats\nopenldap is keg-only, which means it was not symlinked into /usr/local,\nbecause macOS already provides this software and installing another version in\nparallel can cause all kinds of trouble.\n\nIf you need to have openldap first in your PATH, run:\n  echo 'export PATH="/usr/local/opt/openldap/bin:$PATH"' >> ~/.zshrc\n  echo 'export PATH="/usr/local/opt/openldap/sbin:$PATH"' >> ~/.zshrc\n\nFor compilers to find openldap you may need to set:\n  export LDFLAGS="-L/usr/local/opt/openldap/lib"\n  export CPPFLAGS="-I/usr/local/opt/openldap/include"\n\nFor pkg-config to find openldap you may need to set:\n  export PKG_CONFIG_PATH="/usr/local/opt/openldap/lib/pkgconfig"\n\n==> Analytics\ninstall: 119,420 (30 days), 336,001 (90 days), 1,036,075 (365 days)\ninstall-on-request: 14,088 (30 days), 46,874 (90 days), 166,063 (365 days)\nbuild-error: 0 (30 days)\n\nlibiconv: stable 1.16 (bottled) [keg-only]\nConversion library\nhttps://www.gnu.org/software/libiconv/\n/usr/local/Cellar/libiconv/1.16 (30 files, 2.4MB)\n  Poured from bottle on 2021-05-29 at 15:10:22\nFrom: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libiconv.rb\nLicense: GPL-3.0\n==> Caveats\nlibiconv is keg-only, which means it was not symlinked into /usr/local,\nbecause macOS already provides this software and installing another version in\nparallel can cause all kinds of trouble.\n\nIf you need to have libiconv first in your PATH, run:\n  echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.zshrc\n\nFor compilers to find libiconv you may need to set:\n  export LDFLAGS="-L/usr/local/opt/libiconv/lib"\n  export CPPFLAGS="-I/usr/local/opt/libiconv/include"\n\n==> Analytics\ninstall: 5,992 (30 days), 14,923 (90 days), 60,385 (365 days)\ninstall-on-request: 4,364 (30 days), 10,383 (90 days), 39,784 (365 days)\nbuild-error: 0 (30 days)\n(base)\n
Run Code Online (Sandbox Code Playgroud)\n

And*_*eas 0

我对 php@7.3 遇到了同样的问题,可以通过brew reinstall php@7.3 解决它

   Process:               php [34964]
Path:                  /usr/local/Cellar/php@7.3/7.3.28/bin/php
Identifier:            php
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        zsh [33976]
Responsible:           Terminal [33974]
User ID:               501

Date/Time:             2021-05-29 14:54:16.027 +0200
OS Version:            Mac OS X 10.15.7 (19H1030)
Report Version:        12
Anonymous UUID:        27971833-8B1A-565F-AF38-850B51BFF263

Sleep/Wake UUID:       97FB53F8-E8CE-4D13-8B18-35E70FBE222C

Time Awake Since Boot: 200000 seconds
Time Since Wake:       15000 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x1] Library missing

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
  Referenced from: /usr/local/opt/php@7.3/bin/php
  Reason: image not found

Binary Images:
       0x10ed4c000 -        0x10f8adff3 +php (0) <A7799EE4-0502-34CF-8C19-00E2B238B154> /usr/local/opt/php@7.3/bin/php
       0x10faa3000 -        0x10fc62d03 +libcrypto.1.1.dylib (0) <EF694AAC-B437-322C-B619-BF3EB122466C> /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib
       0x10fcff000 -        0x10fd4eff7 +libssl.1.1.dylib (0) <9BD08628-AC20-3489-B3D2-AC117A5BC2F8> /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib
       0x10fd81000 -        0x10fd91fff +libzip.5.dylib (0) <01712EF1-7BA0-3073-ACE4-806C184CE3D5> /usr/local/opt/libzip/lib/libzip.5.dylib
       0x10fd9c000 -        0x10fe1bff3 +libtidy.5.dylib (0) <75C59099-9522-3701-8A22-276C6B65F9AF> /usr/local/opt/tidy-html5/lib/libtidy.5.dylib
       0x10fe5e000 -        0x10fe62ff7 +libargon2.1.dylib (0) <21EA0947-B6AC-33CF-98FF-2458872E1B8D> /usr/local/opt/argon2/lib/libargon2.1.dylib
       0x10fe6a000 -        0x10fea9ffb +libsodium.23.dylib (0) <D8777AB1-B4BA-324E-8E40-FEF56A1E7955> /usr/local/opt/libsodium/lib/libsodium.23.dylib
       0x10fec0000 -        0x10ff0bff3 +libaspell.15.dylib (0) <EE2F1867-CC5D-3417-802E-BF346085A7EC> /usr/local/opt/aspell/lib/libaspell.15.dylib
       0x10ff4b000 -        0x10ff4efff +libpspell.15.dylib (0) <BCDE5138-A654-30CB-BFFC-AA8C02A5F181> /usr/local/opt/aspell/lib/libpspell.15.dylib
       0x10ff53000 -        0x10ff8afff +libpq.5.dylib (0) <A33CB55C-781A-3D74-B9AB-2DD5DD90FB81> /usr/local/opt/libpq/lib/libpq.5.dylib
       0x10ffa0000 -        0x110083ffb +libsqlite3.0.dylib (0) <D721F2B6-F556-3C4C-9D2F-5C5A6B004EF6> /usr/local/opt/sqlite/lib/libsqlite3.0.dylib
       0x1100af000 -        0x1100fefff +libsybdb.5.dylib (0) <8308AD20-05F2-3C4B-906D-4503DB597CFB> /usr/local/opt/freetds/lib/libsybdb.5.dylib
       0x11f328000 -        0x11f3b9f47  dyld (750.6) <1DCAF85D-70A4-3405-A868-25AF3DC1F32B> /usr/lib/dyld
    0x7fff6e04a000 -     0x7fff6e067fff  libedit.3.dylib (55) <96858F68-DEB8-3CEE-B920-C2CF13B96D30> /usr/lib/libedit.3.dylib
    0x7fff6e082000 -     0x7fff6e08effb  libexslt.0.dylib (16.11) <08008EC9-B665-34B6-96AA-3E4D0AD401B7> /usr/lib/libexslt.0.dylib
    0x7fff6eabb000 -     0x7fff6eaeafff  libncurses.5.4.dylib (57) <995DFEEA-40F3-377F-B73D-D02AC59D591F> /usr/lib/libncurses.5.4.dylib
    0x7fff6f23e000 -     0x7fff6f256fff  libresolv.9.dylib (67.40.1) <C57EDFEF-D36A-310B-8D14-8C68A625B1E8> /usr/lib/libresolv.9.dylib
    0x7fff6f813000 -     0x7fff6f825ff3  libz.1.dylib (76) <793D9643-CD83-3AAC-8B96-88D548FAB620> /usr/lib/libz.1.dylib
Run Code Online (Sandbox Code Playgroud)