I'm on Mac OSx, using MAMP. When I run git commands directly in the terminal, they work as expected with no errors. But I'm writing a script in php, that is meant to run some git commands, and I am getting the following error:
exec('cd /my/path/here/ 2>&1 && git init 2>&1', $out, $return);
returns:
Array
(
[0] => dyld: lazy symbol binding failed: Symbol not found: _iconv_open
[1] => Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/git
[2] => Expected in: /Applications/MAMP/Library/lib/libiconv.2.dylib
[3] =>
[4] => dyld: Symbol not found: _iconv_open
[5] => Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/git
[6] => Expected in: /Applications/MAMP/Library/lib/libiconv.2.dylib
[7] =>
)
A search gives a bunch of results (here for example) explaining how this is an OSx / MAMP issue, with the fix being to add export DYLD_LIBRARY_PATH=/usr/lib/
to your .bash_profile
. But as I said, I do not have a problem from the terminal, I only get the error when calling git from php's exec()
. I did add the DYLD_LIBRARY_PATH=...
to my bash_profile
, and it made no difference.
Does calling exec()
not invoke my bash_profile
, even if Apache is set to run as my normal user?