无法在 Mac Big Sur 上安装 PHP yaml 扩展

Kyl*_*son 9 php c macos homebrew yaml

运行pecl install yaml错误configure: error: \xe2\x80\x98yaml.h\xe2\x80\x99 header not found

\n

brew install php@7.4我通过 Homebrew \n 和 libyaml安装了 PHP 7.4.14 brew install libyaml,但仍然看到同样的错误。

\n

我还尝试重新安装 xcode 开发工具,以及使用 sudo 运行 pecl,但每次仍然出现相同的错误。下面是 pecl 的完整输出。

\n
Starting to download yaml-2.2.1.tgz (40,977 bytes)\n............done: 40,977 bytes\n8 source files, building\nrunning: phpize\nConfiguring for:\nPHP Api Version:         20190902\nZend Module Api No:      20190902\nZend Extension Api No:   320190902\nPlease provide the prefix of libyaml installation [autodetect] :\nbuilding in /private/tmp/pear/temp/pear-build-mattfergusonRvLour/yaml-2.2.1\nrunning: /private/tmp/pear/temp/yaml/configure --with-php-config=/usr/local/opt/php@7.4/bin/php-config --with-yaml\nchecking for grep that handles long lines and -e... /usr/bin/grep\nchecking for egrep... /usr/bin/grep -E\nchecking for a sed that does not truncate output... /usr/bin/sed\nchecking for pkg-config... /usr/local/bin/pkg-config\nchecking pkg-config is at least version 0.9.0... yes\nchecking for cc... cc\nchecking whether the C compiler works... yes\nchecking for C compiler default output file name... a.out\nchecking for suffix of executables...\nchecking whether we are cross compiling... no\nchecking for suffix of object files... o\nchecking whether we are using the GNU C compiler... yes\nchecking whether cc accepts -g... yes\nchecking for cc option to accept ISO C89... none needed\nchecking how to run the C preprocessor... cc -E\nchecking for icc... no\nchecking for suncc... no\nchecking for system library directory... lib\nchecking if compiler supports -R... no\nchecking if compiler supports -Wl,-rpath,... yes\nchecking build system type... x86_64-apple-darwin20.2.0\nchecking host system type... x86_64-apple-darwin20.2.0\nchecking target system type... x86_64-apple-darwin20.2.0\nchecking for PHP prefix... /usr/local/Cellar/php@7.4/7.4.14\nchecking for PHP includes... -I/usr/local/Cellar/php@7.4/7.4.14/include/php -I/usr/local/Cellar/php@7.4/7.4.14/include/php/main -I/usr/local/Cellar/php@7.4/7.4.14/include/php/TSRM -I/usr/local/Cellar/php@7.4/7.4.14/include/php/Zend -I/usr/local/Cellar/php@7.4/7.4.14/include/php/ext -I/usr/local/Cellar/php@7.4/7.4.14/include/php/ext/date/lib\nchecking for PHP extension directory... /usr/local/Cellar/php@7.4/7.4.14/pecl/20190902\nchecking for PHP installed headers prefix... /usr/local/Cellar/php@7.4/7.4.14/include/php\nchecking if debug is enabled... no\nchecking if zts is enabled... no\nchecking for gawk... no\nchecking for nawk... no\nchecking for awk... awk\nchecking if awk is broken... no\nchecking whether to enable LibYAML suppot... yes, shared\nchecking for yaml headers... found in /usr/local\nchecking for ANSI C header files... no\nchecking for sys/types.h... yes\nchecking for sys/stat.h... yes\nchecking for stdlib.h... no\nchecking for string.h... yes\nchecking for memory.h... yes\nchecking for strings.h... yes\nchecking for inttypes.h... no\nchecking for stdint.h... no\nchecking for unistd.h... yes\nchecking yaml.h usability... no\nchecking yaml.h presence... no\nchecking for yaml.h... no\nconfigure: error: \xe2\x80\x98yaml.h\xe2\x80\x99 header not found\nERROR: `/private/tmp/pear/temp/yaml/configure --with-php-config=/usr/local/opt/php@7.4/bin/php-config --with-yaml\xe2\x80\x99 failed\n
Run Code Online (Sandbox Code Playgroud)\n

小智 22

也许你应该检查一下。

Please provide the prefix of libyaml installation [autodetect] :
Run Code Online (Sandbox Code Playgroud)

今天我也得到了同样的东西。我尝试输入libyaml前缀解决了。

这是步骤:

步骤1

Please provide the prefix of libyaml installation [autodetect] :
Run Code Online (Sandbox Code Playgroud)

第2步

$brew uninstall libyaml
Uninstalling /opt/homebrew/Cellar/libyaml/0.2.5... (10 files, 369.7KB)
Run Code Online (Sandbox Code Playgroud)

步骤3 复制步骤2中的前缀。

$brew install libyaml 
==> Downloading https://github.com/yaml/libyaml/archive/0.2.5.tar.gz
Already downloaded: /Users/**/Library/Caches/Homebrew/downloads/688fdcea5b88140cb83d1f72e3a77fa76b6560f0d66eabcea7d54cf9f06d5e72--libyaml-0.2.5.tar.gz
==> ./bootstrap
==> ./configure --prefix=/opt/homebrew/Cellar/libyaml/0.2.5
==> make install
  /opt/homebrew/Cellar/libyaml/0.2.5: 10 files, 369.7KB, built in 12 seconds
Run Code Online (Sandbox Code Playgroud)

步骤4

#In this case,It's
/opt/homebrew/Cellar/libyaml/0.2.5
Run Code Online (Sandbox Code Playgroud)

步骤5 粘贴您在步骤3 中复制的消息,然后按回车键。

$sudo pecl install yaml
Password:
downloading yaml-2.2.1.tgz ...
Starting to download yaml-2.2.1.tgz (40,977 bytes)
............done: 40,977 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Please provide the prefix of libyaml installation [autodetect] : 
Run Code Online (Sandbox Code Playgroud)

终于成功了。