25

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 php@7.1-7.1.23.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/php@7.1/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/php@7.1/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 php@7.1`

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?

user3871
  • 12,432
  • 33
  • 128
  • 268

9 Answers9

49

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.

kemp
  • 663
  • 7
  • 23
CommandZ
  • 3,333
  • 1
  • 23
  • 28
14

It's worked for me:

brew reinstall openldap
bakha
  • 311
  • 2
  • 8
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
user3871
  • 12,432
  • 33
  • 128
  • 268
6

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/php@7.1/7.1.23/bin/php

In OP's case, it was php@7.1. In my case it was php@7.3. After I ran the following based on my situation, everything worked

brew uninstall php@7.3
brianjohnhanna
  • 343
  • 4
  • 12
6

For those who can not resolve by brew install openldap libiconv, try below command:

brew reinstall openldap
brew reinstall php@7.4
brew services restart php@7.4
hehe bu
  • 91
  • 1
  • 6
2

This issue is discussed and tracked at https://github.com/Homebrew/homebrew-core/issues/32916

FatherShawn
  • 211
  • 2
  • 8
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/php@5.6/bin:/usr/local/opt/php@5.6/sbin:$PATH
Deepak Rajpal
  • 811
  • 1
  • 8
  • 11
2

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

brew uninstall php

brew install php
codeaprendiz
  • 2,703
  • 1
  • 25
  • 49
1

For me, after running the following commands:

brew reinstall openldap 
brew reinstall php@7.4 
brew services restart php@7.4

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

Dirane
  • 51
  • 5