Composer killed while updating

Viewed 190854

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?

19 Answers

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.

I've got this error when I ran composer install inside my PHP DOCKER container, It's a memory issue. Solved by increasing SWAP memory in DOCKER PREFERENCES from 512MB to 1.5GB

To do that:

Docker -> Preferences -> Rousources

enter image description here

Run composer self-update and composer clearcache 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

If you're using docker you can use COMPOSER_PROCESS_TIMEOUT

environment:
  COMPOSER_MEMORY_LIMIT: -1
  COMPOSER_PROCESS_TIMEOUT: 2000 #seconds

Also in big projects composer needs more RAM than 2GB, you can check that with ps -aux while it is running. You will have to add it manually inside docker options, nothing else will help.

enter image description here

Here's how I succeeded in installing maatwebsite\excel package from composer in Laravel Framework:

  1. I download composer.json file and composer.lock file from my remote server.
  2. I run composer update from local command prompt (then wait until all the install process finished).
  3. Upload composer.lock file to remote server.
  4. run composer install on remote server (then wait until all process finished).
  5. DONE

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

  • Php 7.2 / 7.3
  • nginx
  • ubuntu
  • composer 1.X
  • mariaDB
  • magento 2.3.X

Error : Updating dependencies (including require-dev) Killed for

  1. Ram Must at least 4GB
  2. Change instance type to suitable or Upgrade Ram
  3. Php Memory Value change
  4. Server Restart
  5. Try to install the same package again

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
  

Php 7.3.X

  sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.3/fpm/php.ini

Test if applied on 'free -h' command

    free -h

Install-Package Again#

Install extension via Composer

go to your Magento 2 installation directory

cd /var/www/html/

with 'superuser' privileges

sudo su

Start installation

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
Restart
sudo reboot

Enjioy

I was facing this same issue on my ec2 instance, following steps worked for me :

  1. Copied composer.lock file from my local environment to ec2.
  2. then run sudo composer install and its simply installed all the dependencies for my project.

I solved it maintaining the below steps in my ubuntu server. Hope it will works for you.

  • Stop my apache server

    sudo service apache2 stop

  • Run composer update

    sudo composer update

  • Start my apache server

    sudo service apache2 start

php -d memory_limit=5G composer.phar update

Solved on Laravel/Homestead (Vagrant Windows)

  1. Edit Homestead.yaml and increase memory from 2048 to 4096

  2. vagrant up

  3. vagrant ssh

  4. 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
    

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"

I was using:

  • Virtualbox
  • 4096 Gb RAM
  • 2 CPU
  • 10 GB HDD (500 MB swap)
  • Ubuntu 20.04

Running:

  • composer update in a laravel 8 project folder

I didn't set the swap for the virtual machine, so Virtualbox created a 500Mb swap space, which was NOT enough.

So composer was using 4Gb of RAM plus swap.

I gave more swap space to the VM and then it worked.

As the picture below, composer used all my RAM + 2GB of swap

System Monitor

I was getting this error in a local Docker environment. I solved it by simply restarting Docker.

Related