You’re encountering the “Allocation of JIT memory failed, PCRE JIT will be disabled” error, even though you’ve set pcre.jit=0 in your PHP 7.4 ini file in Herd. Here are a few things you can try to resolve this issue:
1. Double-check the Correct php.ini Location
Herd can use custom configuration files for different PHP versions. Composer may be using a different php.ini than you think. Find out which ini PHP CLI uses:
php -i | grep "Loaded Configuration File"
Make sure that this file has pcre.jit=0 set, not just an ini you edited elsewhere.
2. Set pcre.jit=0 via Command Line as a Test
To ensure the setting is applied, let’s try running Composer with the ini setting overridden:
php -d pcre.jit=0 /path/to/composer install
If you’re using Herd’s global Composer installation, adjust path accordingly:
For example:php -d pcre.jit=0 "$(which composer)" install
If this works, it means your ini file is not being picked up as you expect.
3. Environment/Container Security Restrictions
If Herd is using some sort of sandbox, the system security (like macOS SIP, AppArmor, or SELinux) may block allocating executable memory. You can often work around this by fully disabling JIT (which you tried) or by running Composer with less isolation (not applicable unless using something like Docker).
4. Export Environment Variable
Some people have reported improved reliability by setting an environment variable before running Composer:
export PCRE_JIT=0
Then run your Composer command.
5. Clear and Restart Herd
After changing any .ini files, always restart Herd to ensure it reloads your changes.
If you did this, try a full system reboot as well.
6. Verify Herd is Actually Switching PHP Versions
Sometimes GUI tools like Herd appear to switch PHP versions, but the terminal still uses the system’s PHP.
Check by running:
php -v
which php
Make sure both refer to Herd’s PHP 7.4.
7. Try Composer as a Local PHAR
To rule out issues with Herd’s Composer, try downloading Composer as a PHAR in your project directory:
php -d pcre.jit=0 composer.phar install
Summary
- Double-check the exact
php.iniused by CLI (php -i | grep ini). - Try forcing
pcre.jit=0via the-dCLI flag. - Make sure you’re using Herd’s PHP everywhere.
- Set the environment variable if needed.
- If all else fails, try Composer from a standalone PHAR.
If all the above fails, please share the full output of php -i, and specify if you're running on Intel Mac or Apple Silicon, as certain low-level issues may affect this as well.
Let me know which of these resolves it!