Looks like you runs out of swap memory, try this
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
as mentioned by @BlackBurn027 on comments below, this solution was described in here
As composer troubleshooting guide here This could be happening because the VPS runs out of memory and has no Swap space enabled.
free -m
To enable the swap you can use for example:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
Or if above not worked then you can try create a swap file
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
A bit old but just in case someone new is looking for a solution, updating your PHP version can fix the issue.
Also you should be committing your composer.lock file and doing a composer install on a production environment which is less resource intensive.
More details here: https://github.com/composer/composer/issues/1898#issuecomment-23453850
I have faced the same issue. I am on a AWS Free Microinstance which has less memory. I always try one of the below options and it always works (Before all this please check if you have the latest version of composer installed)
sudo php -dmemory_limit=750M composer.phar update
or remove the contents of the vendor folder and try composer update.
sudo rm -rf vendor
sudo php -dmemory_limit=750M composer.phar update --no-scripts --prefer-dist
sudo php artisan --dump-autoload
The second option tries to update all the components, if there is no update, it picks up the package from the cache else picks up from the dist
Note: Please change the memory limit as per your choice.
or
Create a swap partition and try. Swap partition is the portion of the hard drive that linux uses as virtual memory when it runs out of physical memory. It's similar to the windows swap file only instead of using an actual file, linux uses a partition on the hard drive instead.
Hope this helps
Easy, type this commands:
rm -rf vendor/
rm -rf composer.lock
php composer install --prefer-dist
Should work for low memory machines
Here are the steps to fix the problem: (instant fast SWAP file allocation method used)
Server SWAP Setup (Ubuntu 16.04 SWAP to Fix Out of Memory Errors)
Check if you have swap already, memory and disk size:
sudo swapon -s
free -m
df -h
Make swap file: (change 1G to 4G if you want 4GB SWAP memory)
sudo fallocate -l 1G /swapfile
Check swap file:
ls -lh /swapfile
Assign Swap File:
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Check if swap OK, memory and disk size:
sudo swapon -s
free -m
df -h
Attach Swap File on System Restart:
sudo nano /etc/fstab
/swapfile none swap sw 0 0
Adjust Swap File Settings:
cat /proc/sys/vm/swappiness
cat /proc/sys/vm/vfs_cache_pressure
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50
sudo nano /etc/sysctl.conf
SWAP File Priority: (0-100% => 0: Don't put to swap, 100: Put on SWAP and free the RAM)
vm.swappiness=10
Remove inode from cache: (100: system removes inode information from the cache too quickly)
vm.vfs_cache_pressure = 50
I had a same issue on vagrant. I fixed it by allcate more memory.
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With