I got a problem, I tried to install a new package to my Laravel 4 project.
But when I run
php composer.phar update I get this:
Loading composer repositories with package information Updating dependencies (including require-dev) Killed
I have looked for the problem in the Internet and saw that the memory is the problem, I think I don't have enough RAM available, I've checked this I have about 411mb free. Does composer really need more RAM?
The "Killed" message usually means your process consumed too much memory, so you may simply need to add more memory to your system if possible. At the time of writing this answer, I've had to increase my virtual machine's memory to at least 768MB in order to get
composer update to work in some situations.
However, if you're doing this on a live server, you shouldn't be using
composer update at all. What you should instead do is:
composer updatein a local environment (such as directly on your physical laptop/desktop, or a docker container/VM running on your laptop/desktop) where memory limitations shouldn't be as severe.
git pushthe composer.lock file.
composer installon the live server.
composer install will then read from the .lock file, fetching the exact same versions every time rather than finding the latest versions of every package. This makes your app less likely to break, and composer uses less memory.
Alternatively, you can upload the entire
vendor directory to the server, bypassing the need to run
composer install at all, but then you should run
composer dump-autoload --optimize.
If like me, you are using some micro VM lacking of memory, creating a swap file does the trick:
#Check free memory before free -m mkdir -p /var/_swap_ cd /var/_swap_ #Here, 1M * 2000 ~= 2GB of swap memory. Feel free to add MORE dd if=/dev/zero of=swapfile bs=1M count=2000 chmod 600 swapfile mkswap swapfile swapon swapfile #Automatically mount this swap partition at startup echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab #Check free memory after free -m
As several comments pointed out, don't forget to add sudo if you don't work as root.
btw, feel free to select another location/filename/size for the file.
/var is probably not the best place, but I don't know which place would be, and rarely care since tiny servers are mostly used for testing purposes.
Unfortuantely composer requires a lot of RAM & processing power. Here are a few things that I did, which combined, made the process bearable. This was on my cloud playpen env.
service mysql stop(kill your DB/mem-hog services to free some RAM - don't forget to start it again!)
topto watch memory/swap consumption until process is complete.
composer.phar update --prefer-dist -vvv(verbose output [still hangs at some points when working] and use distro zip files). Maybe try a
DigitalOcean fix that does not require extra memory - activating swap, here is an example for 1gb:
in terminal run below
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1
The above solution will work until the next reboot, after that the swap would have to be reactivated. To persist it between the reboots add the swap file to fstab:
sudo nano /etc/fstab
open the above file add add below line to the file
/var/swap.1 swap swap sw 0 0
now restart the server. Composer require works fine.
composer self-update and
remove vendor and composer.lock
restart your local environment and then run
php -d memory_limit=-1 /usr/local/bin/composer install
Increase the memory limit for composer
php -d memory_limit=4G /usr/local/bin/composer update
Here's how I succeeded in installing maatwebsite\excel package from composer in Laravel Framework:
composer updatefrom local command prompt (then wait until all the install process finished).
composer installon remote server (then wait until all process finished).
If you're using docker you can use COMPOSER_PROCESS_TIMEOUT
environment: COMPOSER_MEMORY_LIMIT: -1 COMPOSER_PROCESS_TIMEOUT: 2000 #seconds
composer 2 update have reduced the memory usage
composer self-update composer update composer require xxx
Fix for AWS ec2 Ubuntu Server Php Memory Value Upgrade For Magento 2.3.X
Error : Updating dependencies (including require-dev) Killed for
PHP value update may locate under '/etc/php/7.2/fpm/php.ini' depend on your server and PHP fpm X.XX version
Using Seed command 'change as your server requires' on my case >> /etc/php/7.2/fpm/php.ini
memory limit type as "3.5G" or "3500MB" Php 7.2.X
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.3/fpm/php.ini
Test if applied on 'free -h' command
Install extension via Composer
go to your Magento 2 installation directory
with 'superuser' privileges
composer require XXXXXX/XXXXXXX
Enable Module s
php bin/magento module:enable XXXXXX/XXXXXXX php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy
I get this problem caused for a package that don't update correctly with wildcards, I use directly the last version and it works finally.
"l3/cas-bundle": "~1.0" -------> "l3/cas-bundle": "1.1.13"
Solved on Laravel/Homestead (Vagrant Windows)
Homestead.yaml and increase memory from 2048 to 4096
Install Symfony with this line on the folder you choose (must be without files)
COMPOSER_MEMORY_LIMIT=-1 composer create-project symfony/website-skeleton . -s dev
php -d memory_limit=5G composer.phar update
I was getting this error in a local Docker environment. I solved it by simply restarting Docker.