Composer killed while updating

后端 未结 16 1801
野性不改
野性不改 2020-11-28 19:40

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          


        
相关标签:
16条回答
  • 2020-11-28 19:47

    Increase the memory limit for composer

    php -d memory_limit=4G /usr/local/bin/composer update
    
    0 讨论(0)
  • 2020-11-28 19:49

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

    0 讨论(0)
  • 2020-11-28 19:56

    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.

    1. You may be simply running out of RAM. Enable swap: https://www.digitalocean.com/community/search?q=add+swap (note: I think best practice is to add a seperate partition. Digitalocean's guide is appropriate for their environment)
    2. service mysql stop (kill your DB/mem-hog services to free some RAM - don't forget to start it again!)
    3. use a secondary terminal session running top to watch memory/swap consumption until process is complete.
    4. composer.phar update --prefer-dist -vvv (verbose output [still hangs at some points when working] and use distro zip files). Maybe try a --dry-run too?
    5. Composer is apparently know to run slower in older versions of PHP (e.g. 5.3x). It was still slow in 5.5.9 for me...
    0 讨论(0)
  • 2020-11-28 19:56

    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

    0 讨论(0)
  • 2020-11-28 19:58

    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:

    1. Run composer update in 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.
    2. Upload or git push the composer.lock file.
    3. Run composer install on 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.

    Read more here: https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock

    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.

    0 讨论(0)
  • 2020-11-28 19:58

    composer 2 update have reduced the memory usage

    composer self-update
    composer update
    composer require xxx
    
    0 讨论(0)
提交回复
热议问题