Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer update `The following exception is caused by a lack of memory and not having swap configured` error in vagrant

I got php5.5 with composer installed in a vagrant VirtualBox environment.

When I try any composer's commands the following error appears randomly:

The following exception is caused by a lack of memory and not having swap configured

How can I get around this ?

like image 932
Raphaël Avatar asked Aug 08 '16 11:08

Raphaël


Video Answer


2 Answers

It isn't a bug and fix it - To enable the swap you can use for example:

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

Ref: https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors

Hope it will help you :)

like image 175
Alex Avatar answered Oct 21 '22 04:10

Alex


Sometimes swap file has not enough memory for composer update, so create a new one:

(assuming existing /swapfile has 2G, create new /swapfile1 with 8G of your drive space)

$ sudo fallocate -l 8G /swapfile1
$ sudo chmod 600 /swapfile1

$ sudo mkswap /swapfile1
$ sudo swapon /swapfile1

after composer updated, you can remove it and keep only initial file:

$ sudo swapoff /swapfile1
$ sudo rm /swapfile1
like image 18
Anatoliy R Avatar answered Oct 21 '22 04:10

Anatoliy R