Skip to content

PHP installed with brew does not automatically install pcre2 #202836

Open
@nbro10

Description

brew gist-logs <formula> link OR brew config AND brew doctor output

brew config

HOMEBREW_VERSION: 4.4.14
ORIGIN: https://github.com/Homebrew/brew
HEAD: f84082963da8af8c9ccd6dffbe932eba457e2b78
Last commit: 24 hours ago
Branch: stable
Core tap JSON: 31 Dec 13:14 UTC
Core cask tap JSON: 31 Dec 13:14 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 14
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 14-core 64-bit arm_palma
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 14.6.1-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 16.2
Rosetta 2: false

brew doctor

Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was trying to install apcu with pecl install apcu2.

Note that pecl and pear seem to come with the PHP installed with brew, that's why I'm opening the issue here, as I think that this issue is related to the PHP installation with brew - pcre2 should also be installed when installing PHP.

What happened (include all command output)?

I get this error

...
ivate/tmp/pear/temp/pear-build-nbros8mwyT/apcu-5.1.24/main -I/private/tmp/pear/temp/apcu -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/main -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/TSRM -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/Zend -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/ext -I/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Wall -Wextra -Wno-unused-parameter -DZEND_COMPILE_DL_EXT=1 -c /private/tmp/pear/temp/apcu/php_apc.c -MMD -MF php_apc.dep -MT php_apc.lo  -fno-common -DPIC -o .libs/php_apc.o
In file included from /private/tmp/pear/temp/apcu/php_apc.c:34:
In file included from /private/tmp/pear/temp/apcu/apc_iterator.h:26:
/opt/homebrew/Cellar/[email protected]/8.2.27/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
   23 | #include "pcre2.h"
      |          ^~~~~~~~~
1 error generated.
make: *** [php_apc.lo] Error 1
ERROR: `make' failed

Now, APCu is a replacement for APC. See https://www.php.net/manual/en/book.apcu.php.

According to the PHP docs https://www.php.net/manual/en/pcre.installation.php

The PCRE extension is a core PHP extension, so it is always enabled. By default, this extension is compiled using the bundled PCRE library. Alternatively, an external PCRE library can be used by passing in the --with-pcre-regex=DIR configuration option where DIR is the location of PCRE's include and library files. It is recommended to use PCRE 8.10 or newer; as of PHP 7.3.0, PCRE2 is required.

If I do php -m, I don't get pcre2

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
random
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PCRE2: https://github.com/PCRE2Project/pcre2

What did you expect to happen?

If APCu uses PCRE2 and version 8 of PHP requires PCRE2, then, when you install PHP 8 with brew, PCRE2 should also be installed automatically and linked correctly.

Step-by-step reproduction instructions (by running brew commands)

1. `brew install [email protected]` (or php or [email protected]), then export the bin folder to the path, so that `php` points to this version
2. `pecl install apcu`

If I do brew list | grep pcre2, I actually get pcre2, so it's installed, but probably not linked correctly.

In fact, if I do brew uses pcre2 --installed, I also get that also PHPs depend on it

Other

See also https://stackoverflow.com/q/72039019 e.g.

Metadata

Assignees

No one assigned

    Labels

    bugReproducible Homebrew/homebrew-core bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions