citizen_of_noobville
citizen_of_noobville

Reputation: 327

Composer Fails to Install and Update

I was doing the same thing in my server weeks ago, but now I can't. Here's my error output:

composer install

Loading composer repositories with package information
Installing dependencies (including require-dev)
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:974
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(793): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(754): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(688): Symfony\Component\Console\Application->getTerminalWidth()
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974

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:974
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(793): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(754): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(688): Symfony\Component\Console\Application->getTerminalWidth()
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974`

Upvotes: 0

Views: 4980

Answers (8)

Tuychiev Toir
Tuychiev Toir

Reputation: 370

this is working for me php -dmemory_limit=1GB $(which composer) update

Upvotes: 0

Shailesh Kumar
Shailesh Kumar

Reputation: 47

To solve this problem you have run 2 command.
shailesh@ubuntu$ /var/www$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
Output will be looking like this:
1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 13.1359 s, 81.7 MB/s

and after that run
shailesh@ubuntu$ sudo /sbin/mkswap /var/swap.1
Output will be like:
Setting up swapspace version 1, size = 1048572 KiB no label, UUID=486b676c-aa2a-4329-9783-6d1e6a9eb0a5

and final command you have to run
shailesh@ubuntu$ sudo /sbin/swapon /var/swap.1

Now run composer update and save time.

Upvotes: 0

VIPIN A ROY
VIPIN A ROY

Reputation: 1781

To solve this issue, increase the swap memory:

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

Upvotes: 2

Artjom Kurapov
Artjom Kurapov

Reputation: 6155

Had similar issues with updating symfony project with large dependencies. Creating swap file helped: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04

Upvotes: 0

surya
surya

Reputation: 1359

If you are running under virtual environment like vagrant for instance, then make sure swap is enabled. Run below script to create swap

#!/bin/sh

# size of swapfile in megabytes
swapsize=512

# does the swap file already exist?
grep -q "swapfile" /etc/fstab

# if not then create it
if [ $? -ne 0 ]; then
   echo 'swapfile not found. Adding swapfile.'
   fallocate -l ${swapsize}M /swapfile
   chmod 600 /swapfile
   mkswap /swapfile
   swapon /swapfile
   echo '/swapfile none swap defaults 0 0' >> /etc/fstab
else
   echo 'swapfile found. No changes made.'
fi

# output results to terminal
cat /proc/swaps
cat /proc/meminfo | grep Swap

source: http://www.nyayapati.com/srao/2014/05/youcompleteme-install-fails-due-to-internal-compiler-error/

Upvotes: 1

shivanshu patel
shivanshu patel

Reputation: 778

I was facing same issue below update command fixed my problem.

sudo composer self-update

//this will set memory. php -dmemory_limit=-1 composer update

or

sudo php -dmemory_limit=-1 composer update

Upvotes: 0

citizen_of_noobville
citizen_of_noobville

Reputation: 327

Adding composer.lock to tracked files solved the problem.

git add -f composer.lock
git add .
git commit -m 'remove composer.lock from ignored files'
git push

and then,

git clone ....

in server.

Problem solved.

Thanks anyway.

Upvotes: 1

WordsWorth
WordsWorth

Reputation: 872

I once had this problem, increasing memory limit solved it. You can give it a try.

Upvotes: 3

Related Questions