'php dyld: Library not loaded for libldap
I installed ruby on my Mac OSX High Sierra and am running into issues now with my php installation for some reason. I'm on php 7.1.
Following this (also here) Github suggestion, I tried
brew update && brew reinstall php71
While installing, it broke at
==> Pouring [email protected]_sierra.bottle.tar.gz
==> /usr/local/Cellar/[email protected]/7.1.23/bin/pear config-set php_ini /usr/local/etc/php/7.1/php.ini system
With error:
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/Cellar/[email protected]/7.1.23/bin/php
Reason: image not found
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
Typing in php into terminal throws the same error.
Other things I've tried:
- I thought perhaps it wasn't linked, so I also tried:
brew unlink libldap && brew link libldap- butlibldapis not supported by Homebrew - Then here, while unrelated to postgres, it does discuss the issue of
libldapand says to install viabrew install openldap(I guesslibldapis referred to asopenldapto Homebrew) - this installed fine but didn't resolve the issue
How can I fix this?
Solution 1:[1]
It's worked for me:
brew reinstall openldap
Solution 2:[2]
Although I'm not sure why installing Ruby caused the issue, I solved the issue ultimately with:
- According to this discussion,
libldapis referred to asopenldapto Homebrew.brew install openldapthen ranphp reinstall php71. This linked the libraries properly - The next issue was with
libiconv, fortunately this is easily installed withbrew install libiconv. Rerunningphp install php71solved the problem
Solution 3:[3]
I specifically had to uninstall the offending version. You can grab this broken version from the line that looked like this:
Referenced from: /usr/local/Cellar/[email protected]/7.1.23/bin/php
In OP's case, it was [email protected]. In my case it was [email protected]. After I ran the following based on my situation, everything worked
brew uninstall [email protected]
Solution 4:[4]
This issue is discussed and tracked at https://github.com/Homebrew/homebrew-core/issues/32916
Solution 5:[5]
if you have two PHP running via brew as well a XAMPP, there could be issue in environment path in .bash_profile.
which php
Try above command to see current php path. If it not accurate, set appropriate path and comment other.
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
#export PATH=”/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/sbin:$PATH
Solution 6:[6]
After trying all above solutions. Finally uninstalling and reinstalling worked for me.
brew uninstall php
brew install php
Solution 7:[7]
For those who can not resolve by brew install openldap libiconv,
try below command:
brew reinstall openldap
brew reinstall [email protected]
brew services restart [email protected]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bakha |
| Solution 2 | user3871 |
| Solution 3 | brianjohnhanna |
| Solution 4 | FatherShawn |
| Solution 5 | Deepak Rajpal |
| Solution 6 | codeaprendiz |
| Solution 7 | hehe bu |
