Yamen Ashraf
Yamen Ashraf

Reputation: 2960

Homebrew upgrade drops PHP: dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib

Today I upgraded Homebrew and this causes PHP versions (7.2 - 7.3) to be dropped. the following error is shown whenever I try to reinstall them:

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

Any suggestions?

Upvotes: 22

Views: 22033

Answers (6)

pensebien
pensebien

Reputation: 554

I also had a similar problem. This is how I fix the issue after following a combination of instructions from here and also SO from here

  1. I rename the file.

    locate libtiff

in my case I could see that the file is locate here 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
  1. Then I installed both gd then I had this error

    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
    
  2. brew reinstall gd after change the libtiff.5.dylib back libtiff.6.dylib as in STEP 1. This is just to make sure nothing breaks in the future.

     brew reinstall gb
    

    hereenter image description here

Now when I do php -v the issue is fixed. enter image description here

I actually got here after trying to use wp plugin list after brew upgrade.

Upvotes: 0

dustbuster
dustbuster

Reputation: 82172

I found various anwers to this, but basically I broke the permissions of my Cellar Directory and everything in it by running a stupid command trying to fix an error after installing NMAP.

So to fix it, I reinstalled brew and everything php related. That will correct any permissions and/or sym links. Sometimes you just gotta nuke everything and start over.

This is my specific error:

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)

This error occured any time i used php. Even php -v!

But before doing any of this, try brew update and brew upgrade you might just get lucky and nip it in the bud before you get into process of removing ALL php versions and reinstalling. But these are the steps i took to fix this error.

  1. rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
  2. Then follow instructions here: docs.brew.sh/Installation to install brew. (as they change from time to time)
  3. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  4. remove all versions of php
  5. brew search php See if you have any remaining [email protected] check marks next to the php versions, remove those with brew uninstall [email protected]
  6. i.e. brew uninstall brew-php-switcher (if you use it)
  7. brew upgrade
  8. brew cleanup
  9. Then Re-install your php verisons. e.g. brew install [email protected]
  10. Then Re-install brew-php-switcher (if you use it, i love it) brew install brew-php-switcher
  11. Then once you're done, brew-php-swticher 8.2 I love this tool! (Or replace 8.2 with what version you need, just use 7.4 or 8.0 etc)

Upvotes: 2

I've solved this by doing the following

brew uninstall libpsl
brew remove php
brew install libpsl
brew install [email protected]

Upvotes: -1

Rafael Corr&#234;a Gomes
Rafael Corr&#234;a Gomes

Reputation: 1907

Removing the Cellar folder and installing the PHP again worked for me.

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

Upvotes: 2

Simba
Simba

Reputation: 27758

It's a bug after php was migrated to OpenSSH 1.1. There's no need to install libpsl.

The problem has been fixed by pr-44048. You should uninstall libpsl and reinstall php.

brew uninstall libpsl
brew reinstall php

Upvotes: 4

Yamen Ashraf
Yamen Ashraf

Reputation: 2960

Okay, I've solved this by installing this library brew install libpsl

then reinstall php brew reinstall [email protected] --build-from-source

also the same for [email protected]

Be aware that reinstalling php will reset all php configurations

Upvotes: 49

Related Questions