我试图通过Composer在Magento 2上安装扩展,但是当我运行Composer更新时,出现以下错误:
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 memory_limit=-1 composer update
但是我得到:
Could not open input file: 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
所以我再次尝试了作曲家更新并得到:
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
并得到
Could not open input file: composer
我回到了我开始的地方,感到非常困惑:/请告知。谢谢。
答案 0 :(得分:0)
在使用php -d memory_limit=-1
时,您正在动态设置ini
条目,但仅针对通过该命令运行的脚本。
您运行此命令的想法接近您想要实现的目标:
php -d memory_limit=-1 composer update
您唯一需要了解的是composer
可以作为命令运行的事实,因为它位于您的操作系统会查找所有可执行文件的位置(很可能是/usr/bin/composer
,/usr/local/bin/composer
,或类似的东西,通常称为PATH
。但是,当您尝试运行php composer
时,composer仅被视为常规文件,并且您的操作系统不再尝试查找可执行文件路径。
您仍然可以使用命令which
,该命令将为您返回该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
获取更新。
请注意:在作曲家文档中有一篇有关内存限制的完整文章:https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
这可能会减轻您的工作负担,更改相关的PHP CLI
设置,或者可能使您了解
COMPOSER_MEMORY_LIMIT=-1 composer install
和
COMPOSER_MEMORY_LIMIT=-1 composer update