I had this weird issue that seems to be related to macOS Big Sur and MAMP, allegedly, either both combined or when upgrading any of those two (or both?).
I don't know exactly why this happened to me out of the sudden (I blame MAMP as it was the last thing that I updated) but I managed to fix it anyway.
PHP Warning: PHP Startup: Unable to load dynamic library 'pgsql.so' (tried: /Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/pgsql.so (dlopen(/Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/pgsql.so, 9): Library not loaded: /Applications/MAMP/Library/pg/lib/libpq.5.dylib
Referenced from: /Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/pgsql.so
Reason: image not found), /Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/pgsql.so.so (dlopen(/Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/pgsql.so.so, 9): image not found)) in Unknown on line 0
To get around this situation, many suggest to update Brew with
brew update. That didn't work for me (and to be honest I can't see what's the relationship with Brew and MAMP) but you can give it a try anyway since it's easy to do.
What's interesting about the error above is that it mentions
pgsql.so.so which is clearly wrong because of the double
So how do I actually fix this issue?
Go to that
extensions subfolder mentioned in the error (for example, mine is
/Applications/MAMP/bin/php/php7.3.21/lib/php/extensions/no-debug-non-zts-20180731/) and create a symlink for
pdo_pgsql.so.so by doing:
ln -s pdo_pgsql.so pdo_pgsql.so.so
Now it doesn't matter what MAMP is looking for as it will find it either way.
That's not all. Go to
/Applications/MAMP/Library/pg/lib and you'll notice something really weird which are broken paths for the symlinks
libpq.dylib as seen below.
Again, how that happened is another mystery. But it doesn't matter, let's just fix those symlinks by deleting them and creating them again.
ln -s libpq.5.7.dylib libpq.5.dylib;
ln -s libpq.5.7.dylib libpq.dylib;
As you can see on the previous screenshot, the symlink
libpq.5.dylib points to a broken path for
libpq.5.7.dylib which is basically right there on the same folder. The same goes for
At the end everything should look like the following: