Errors installing Composer on macOS (JIT compilation failed)

33,779

Solution 1

This is a known PHP 7.3 bug, which has already been fixed.

As a temporary workaround, edit your php.ini file (in my case: vi /usr/local/etc/php/7.3/php.ini), disable PHP PCRE JIT compilation by changing:

;pcre.jit=1

to

pcre.jit=0

Solution 2

I solved this by disabling the PCRE jit compilation.

I suppose you installed php 7.3 through homebrew.

If so, create a zzz-myphp.ini in /usr/local/etc/php/7.3/conf.d with the following content:

; My php.ini settings
; Fix for PCRE "JIT compilation failed" error
[Pcre]
pcre.jit=0

Solution 3

Other answers suggest disabling PCRE JIT via a configuration file. That works, but caveat: this disables PCRE JIT for all engine invocations that use those INI files. You therefore won't be getting JIT improvement for a potentially wider swath of functionality, which may not be desired.

You can disable JIT for composer only via:

php -d pcre.jit=0 composer.phar ...

Solution 4

In PHP 7.1.24 there is no 'pcre.jit' in php.ini file so you have to set memory_limit:128M (if you increase this).

Solution 5

It work for me by follow steps:

  1. Open you Terminal and run php --ini
  2. Open file php.ini in the path "Loaded Configuration File: /usr/local/php5/lib/php.ini" https://prnt.sc/p9tspy
  3. Find pcre.jit and change ;pcre.jit=1 to pcre.jit=0
Share:
33,779
sheraz m
Author by

sheraz m

Updated on July 08, 2022

Comments

  • sheraz m
    sheraz m almost 2 years

    When I run composer --version in the macOS terminal, I get the following errors.

    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

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

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

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

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

    Warning: preg_split(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php
    

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

    Warning: preg_split(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php
    

    on line 1091 PHP Warning: preg_replace(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Formatter/OutputFormatter.php on line 36

    Warning: preg_replace(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Formatter/OutputFormatter.php
    

    on line 36

      [ErrorException]                                          
      preg_match_all(): JIT compilation failed: no more memory
    
  • Umbrella
    Umbrella over 5 years
    Is that explicitly telling composer to simply run on PHP 5.x?
  • sheraz m
    sheraz m over 5 years
    @Umbrella Exactly. Its setting up a path for execution of composer.
  • bishop
    bishop over 5 years
    Downgrading PHP also works, but is quite extreme. Perhaps invoking with -d pcre.jit=0 or adding same to a configuration file would allow you to continue using version 7 without the trouble.
  • Ben Hillier
    Ben Hillier over 5 years
    What happens when something you try to install via composer has php 7 as a requirement? Not to mention the fact that you're keeping a PHP version on your computer that is officially End-of-life.
  • Jeff Puckett
    Jeff Puckett about 5 years
    this will disable it completely. to just disable it for composer, see bishop's answer stackoverflow.com/a/53772696/4233593
  • Petruza
    Petruza almost 5 years
    I did this on the loaded php.ini but PCRE JIT is still enabled.
  • Deepak Daniel
    Deepak Daniel about 4 years
    This was a very clear step by step explanation. Thank you.
  • pythonbuddha
    pythonbuddha over 3 years
    my command line interface gives error that it does not have right to write.
  • Sandip Jha
    Sandip Jha over 3 years
    But in my file pcre.jit not available what should i need to do ?