【发布时间】:2014-11-24 16:35:04
【问题描述】:
我在 Mac OSx 上,使用 MAMP。当我直接在终端中运行 git 命令时,它们按预期工作,没有错误。但是我正在用 php 编写一个脚本,该脚本旨在运行一些 git 命令,并且出现以下错误:
exec('cd /my/path/here/ 2>&1 && git init 2>&1', $out, $return);
返回:
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] =>
)
搜索会给出一堆结果(例如here),说明这是一个 OSx / MAMP 问题,解决方法是将export DYLD_LIBRARY_PATH=/usr/lib/ 添加到您的.bash_profile。但正如我所说,我从终端没有问题,我只在从 php 的exec() 调用 git 时得到错误。我确实将DYLD_LIBRARY_PATH=... 添加到我的bash_profile 中,但没有任何区别。
调用exec() 不会调用我的bash_profile,即使Apache 设置为我的普通用户运行?
【问题讨论】: