PHP Composer 更新“无法分配内存"错误(使用 Laravel 4)

2022-01-08 00:00:00 php laravel composer-php laravel-4

我就是解决不了这个问题.

I just can't solve this one.

我正在使用 Linode 1G RAM 基本计划.试图通过 Composer 安装一个包,它不让我.我的内存限制在 PHP.ini 上设置为-1"

I'm on Linode 1G RAM basic plan. Trying to install a package via Composer and it's not letting me. My memory limit is set to "-1" on PHP.ini

我还能做些什么来安装它吗?

Is there anything else I can do to get this installed?

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing thujohn/rss (dev-master df80a7d)
    Downloading: 100%         
PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:975
Stack trace:
#0 [internal function]: ComposerUtilErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 975, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(975): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(853): SymfonyComponentConsoleApplication->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(818): SymfonyComponentConsoleApplication->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(752): SymfonyComponentConsoleApplication->getTerminalWidth()
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 975

Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:975
Stack trace:
#0 [internal function]: ComposerUtilErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 975, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(975): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(853): SymfonyComponentConsoleApplication->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(818): SymfonyComponentConsoleApplication->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(752): SymfonyComponentConsoleApplication->getTerminalWidth()
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 975

推荐答案

有点老了,但以防万一新人正在寻找解决方案,更新您的 PHP 版本可以解决问题.

A bit old but just in case someone new is looking for a solution, updating your PHP version can fix the issue.

您还应该提交您的 composer.lock 文件并在资源密集型较少的生产环境中安装 composer.

Also you should be committing your composer.lock file and doing a composer install on a production environment which is less resource intensive.

更多细节在这里:https://github.com/composer/composer/issues/1898#issuecomment-23453850

相关文章