php 在 macOS 上安装 Composer 时出错(JIT 编译失败)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53690624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:54:43  来源:igfitidea点击:

Errors Installing Composer on macOS (JIT compilation Failed)

phpmacoscomposer-phpjitphp-7.3

提问by sheraz m

When I run composer --versionin the macOS terminal I get the following errors:

当我composer --version在 macOS 终端中运行时,出现以下错误:

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

PHP 警告:preg_match():JIT 编译失败:第 755 行的 phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.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
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

回答by Karl Hill

This is a known PHP 7.3 bug.

这是一个已知的 PHP 7.3错误

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

作为临时修复,编辑您的 php.ini 文件(在我的情况下vi /usr/local/etc/php/7.3/php.ini:),通过更改禁用 PHP PCRE JIT 编译:

;pcre.jit=1

to

pcre.jit=0

回答by fab120

I solved this by disabling the PCRE jit compilation.

我通过禁用 PCRE jit 编译解决了这个问题。

I suppose you installed php 7.3 through homebrew.

我想你通过自制软件安装了 php 7.3。

If so, create a zzz-myphp.iniin /usr/local/etc/php/7.3/conf.dwith the following content:

如果是这样,创建一个zzz-myphp.ini/usr/local/etc/php/7.3/conf.d使用以下内容:

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

回答by bishop

Other answers suggest disabling PCRE JIT via a configuration file. That works, but caveat: this disables PCRE JIT for allengine 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.

其他答案建议通过配置文件禁用 PCRE JIT。这可行,但需要注意:这会为使用这些 INI 文件的所有引擎调用禁用 PCRE JIT 。因此,您不会因为潜在的更广泛的功能而获得 JIT 改进,这可能是不希望的。

You can disable JIT for composeronly via:

composer只能通过以下方式禁用 JIT :

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

回答by Ashish Sharma

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).

在 PHP 7.1.24 中没有 'pcre.jit'php.ini 文件,所以你必须设置 memory_limit:128M(如果你增加它)。

回答by ??ng Qu?c Anh

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
  1. 打开终端并运行 php --ini
  2. 在路径“加载的配置文件:/usr/local/php5/lib/php.ini”中打开文件php.ini https://prnt.sc/p9tspy
  3. 找到 pcre.jit 并将 ;pcre.jit=1 改为 pcre.jit=0

回答by Kristin Green

I got the same error. I installed MAMP 5.4 on my Mac OS 10.11.6 using PHP 7.3.7 and installed Composer. It seemed to work but as soon as I attempted to install Yii2 or even check the version, it gave me the error...

我得到了同样的错误。我使用 PHP 7.3.7 在 Mac OS 10.11.6 上安装了 MAMP 5.4 并安装了 Composer。它似乎有效,但是当我尝试安装 Yii2 甚至检查版本时,它给了我错误...

$composer.phar --version
Fatal error: Uncaught ErrorException: preg_match_all(): JIT compilation failed: no more memory in phar:///Users/kristin/Sites/htdocs/composer.phar/vendor/symfony/console/Formatter/OutputFormatter.php:137

Increasing the memory_limit in php.ini from 128M to anything did NOT solve the issue and pcre.jit=1 was commented out so turning it off didn't do anything either.

将 php.ini 中的 memory_limit 从 128M 增加到任何都没有解决问题,并且 pcre.jit=1 被注释掉,所以关闭它也没有做任何事情。

Here is what worked:

这是有效的:

I simply changed the export path to the previous version's directory (without actually downgrading in MAMP's preferences) and it worked!

我只是将导出路径更改为以前版本的目录(实际上并没有在 MAMP 的首选项中降级)并且它起作用了!

$export PATH=/Applications/MAMP/bin/php/php7.2.20/bin:$PATH
$composer.phar --version
Composer version 1.9.0 2019-08-02 20:55:32

If anyone can explain why this worked, I'd appreciate knowing. Cheers.

如果有人能解释为什么这行得通,我很高兴知道。干杯。

回答by sheraz m

Thanks for the answers.. I solved it by command composer.phar and then export path. Example:

感谢您的回答。我通过命令 composer.phar 解决了它,然后导出路径。例子:

$composer.phar
$export PATH=/usr/local/php5/bin:$PATH
$composer.phar --version