Composer php 无法更新Composer';内存大小

Composer php 无法更新Composer';内存大小,composer-php,magento2,Composer Php,Magento2,我正试图通过Composer在Magento 2上安装扩展,但在运行Composer update时,出现以下错误: composer update Loading composer repositories with package information Updating dependencies (including require-dev) Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried t

我正试图通过Composer在Magento 2上安装扩展,但在运行Composer update时,出现以下错误:

 composer update

Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
我尝试:
php-d内存\u限制=-1编写器更新
但我得到:
无法打开输入文件:composer

所以我试着得到了:

curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.9.0) successfully installed to: /home/customer/www/xxx/public_html/composer.phar
Use it: php composer.phar
php -d memory_limit=-1 composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
所以,我认为这是固定的,我再次尝试并得到:

curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.9.0) successfully installed to: /home/customer/www/xxx/public_html/composer.phar
Use it: php composer.phar
php -d memory_limit=-1 composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
因此,我再次尝试了composer update并获得:

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

因此,我再次尝试
composer update
并获得
无法打开输入文件:composer


我又回到了我开始的地方,非常困惑:/请告诉我。谢谢。

当您使用
php-d memory\u limit=-1
时,您正在动态设置
ini
条目,但仅针对通过该命令运行的脚本

您运行此命令的想法接近您想要实现的目标:

php -d memory_limit=-1 composer update
您必须知道的唯一一件事是,
composer
作为一个命令工作,因为它位于操作系统查找所有可执行文件的某个位置(很可能是
/usr/bin/composer
/usr/local/bin/composer
,或者类似的东西,这通常被称为
路径。但是,当您尝试运行
php composer
时,composer只是被视为一个常规文件,并且您的操作系统不再尝试查看您的可执行路径

您仍然可以使用该命令,该命令将返回该
编写器
可执行文件的路径

$ php $(which composer) -V
Composer version 1.8.6 2019-06-11 15:03:05
因此,您应该能够通过以下方式实现您的目标:

php -d memory_limit=-1 $(which composer) install
用于安装包装;及

php -d memory_limit=-1 $(which composer) update
更新

请注意:composer文档中有一篇关于内存限制的完整文章:

这可能会简化您的工作,更改相关的
PHPCLI
设置,或者指出

COMPOSER_MEMORY_LIMIT=-1 composer install


因此,尝试使用composer full path,再次尝试,它看起来可以正常工作,但当我尝试composer Update时,仍然会收到内存不足警告您的内存限制在2GB左右。您正在使用32位PHP吗?通常,Composer会试图自行管理其内存限制,但我认为Magento正在创建巨大的依赖关系图。