Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer proc_open(): fork failed - Cannot allocate memory

I have this same error as others when running php ~/composer.phar update:

The following exception is caused by a lack of memory and not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:974
Stack trace:
0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///home/te...', 974, Array)
1 phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
2 phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(784): Symfony\Component\Console\Application->getSttyColumns()
3 phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(745): Symfony\Component\Console\Application->getTerminalDimensions()
4 phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(675): Symfony\Component\Console\Application->getTerminalWidth()
5 phar:///home/tea/composer in phar:///home/tea/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974

...but with a large instance: 4gb RAM and 4gb swap. The free RAM is never exhausted, let alone the available/cached RAM, and the swap isn't touched!

              total        used        free      shared  buff/cache   available
Mem:           3788         885        1908           9         993        2692
Swap:          3967           0        3967

It's the first time running composer update on this new machine, CentOS/CloudLinux 7.1 (with cPanel).

In desperation, I've tried # php -dmemory_limit=1G ../composer.phar update --no-scripts --prefer-dist and I've tried removing the composer.lock and vendor files and even tried adding a temporary swap file but it really doesn't seem to be a memory problem - could the error be misguided?

proc_open is not disabled and I also tried with shell fork bomb protection disabled but no jive.

Would love a heads up.

N.B. I'm aware of the advice to commit the composer.lock file and do a composer install but this instance is being used for dev (as was the previous CentOS/CloudLinux 6.x machine with smaller resource specs) so we need to use the same methods we were using previously.

like image 662
Pdiggity Avatar asked Jun 03 '15 04:06

Pdiggity


1 Answers

I ran into the same problem. My system had 1.5GB RAM free and it was not enough...Composer was eating too much memory very fast.

My only solution was to clear cache and update to latest version (1.4.2):

composer clear-cache

sudo composer selfupdate
like image 122
vicxyz Avatar answered Oct 16 '22 00:10

vicxyz