Errors installing Composer on macOS (JIT compilation failed)

Errors installing Composer on macOS (JIT compilation failed)

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Errors installing Composer on macOS (JIT compilation failed)

Running composer --version or attempting to run any command on your macOS terminal might trigger a cascade of warnings that look like memory exhaustion but are actually related to Just-In-Time (JIT) compilation limits in the underlying PHP runtime. You will see messages like:

PHP Warning: preg_match(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php on line 755

These warnings repeat for functions such as preg_split, preg_replace, and preg_match_all. They all stem from the same root cause: the PHP JIT engine has hit a memory cap while trying to compile regular expressions at runtime.

Composer is distributed as a PHAR archive on macOS, which bundles its dependencies into a single file. The Symfony Console component (used by Composer) relies heavily on PCRE regex operations for parsing arguments and formatting output. When these operations are executed under PHP JIT, the engine attempts to cache compiled bytecodes in memory. If the system's available heap for JIT compilation is too small relative to the complexity of the regex patterns, compilation fails with "no more memory" errors.

This is not a bug in Composer itself; it is a configuration limit within the PHP interpreter that runs the PHAR. The default JIT settings on recent macOS versions (especially those running Apple Silicon or updated Intel-based systems) often impose strict heap constraints to prevent unbounded memory growth, but these can be too conservative for heavy regex workloads.

To resolve this without switching your entire system's PHP configuration, you can adjust the JIT compilation limits specifically for the PHAR execution context. One approach is to set environment variables that influence how PHP handles JIT compilation when invoked via the CLI.

Try running Composer with an explicit flag to disable JIT compilation entirely:

php -d jit=off /usr/local/bin/composer.phar --version

If you are using a custom-installed version of Composer (not the official PHAR), you can create or edit a composer.jsonrc file in your home directory and add:

{
    "config": {
        "platform": {
            "php": "8.0"
        }
    }
}

However, this does not directly address the JIT issue. The most reliable fix remains adjusting the PHP runtime settings. On macOS, you can set the jit_heap_size parameter to a higher value before invoking Composer:

php -d jit=on -d jit_max_traces=2048 -d jit_profiling=0 /usr/local/bin/composer.phar --version

If these flags are not recognized, your PHP version may not support JIT compilation at all. In that case, ensure you are running a PHP version that includes JIT support (PHP 8.1+ on most platforms). If your system PHP is older but you need Composer to work, consider using a newer PHP binary via Homebrew or a containerized environment like Docker, where you can control the php.ini settings directly:

; Add to php.ini in your Docker container or local install
jit=on
jit_max_traces=2048
jit_max_depth=16
jit_heap_size=512M

Another practical workaround is to avoid running Composer as a PHAR and instead download the source tarball or use a dedicated global installation script that places binaries in a directory with full control over its php.ini. This gives you the flexibility to tune JIT settings globally for your development environment.

If you are deploying this setup to production, keep in mind that increasing JIT heap size can increase memory footprint during peak load. Monitor your application's memory usage after applying these changes to ensure you do not hit system limits under high concurrency.

For teams managing multiple environments, consider documenting these PHP flags alongside the Composer installation instructions to prevent future confusion when developers encounter JIT-related warnings on macOS systems.

Our network