php dyld: Library not loaded for libldap
Asked Answered
P

9

26

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 - but libldap is not supported by Homebrew
  • Then here, while unrelated to postgres, it does discuss the issue of libldap and says to install via brew install openldap (I guess libldap is referred to as openldap to Homebrew) - this installed fine but didn't resolve the issue

How can I fix this?

Polynesian answered 13/10, 2018 at 16:42 Comment(1)
I shared a working solution here https://mcmap.net/q/535438/-how-to-solve-error-of-library-not-loadedIconology
C
51

According to this issue, you need to install openldap and libiconv.

brew install openldap libiconv

I tried it and it worked for my system. I was originally missing the PHP intl extension.

Cagliari answered 17/10, 2018 at 22:13 Comment(0)
J
15

It's worked for me:

brew reinstall openldap
Jewelfish answered 25/6, 2021 at 12:52 Comment(0)
P
8

Although I'm not sure why installing Ruby caused the issue, I solved the issue ultimately with:

  • According to this discussion, libldap is referred to as openldap to Homebrew. brew install openldap then ran php reinstall php71. This linked the libraries properly
  • The next issue was with libiconv, fortunately this is easily installed with brew install libiconv. Rerunning php install php71 solved the problem
Polynesian answered 13/10, 2018 at 17:19 Comment(0)
P
7

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]
Pickwickian answered 3/1, 2022 at 20:31 Comment(0)
F
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]
Ferdinandferdinanda answered 1/3, 2022 at 5:24 Comment(0)
B
2

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
Breadthways answered 26/5, 2021 at 13:32 Comment(0)
B
2

After trying all above solutions. Finally uninstalling and reinstalling worked for me.

brew uninstall php

brew install php
Bred answered 23/12, 2021 at 8:21 Comment(0)
D
1

For me, after running the following commands:

brew reinstall openldap 
brew reinstall [email protected] 
brew services restart [email protected]

I had to restart my computer for the error to stop and everything worked fine.

Dibranchiate answered 4/11, 2022 at 4:16 Comment(0)
D
1

try to upgrade your version

➜  brew upgrade shivammathur/php/[email protected]         
Dafodil answered 9/11, 2023 at 8:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.