composer killed while updating

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

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? Can someone help me please?

Thanks

回答1:

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 (either your local physical machine, or a development virtual machine)
  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#composer-lock-the-lock-file



回答2:

If like me, you are using some micro VM lacking of memory, creating a swap file does the trick :

free -m mkdir -p /var/_swap_ cd /var/_swap_ #Here, 1M * 2000 ~= 2GB of swap memory dd if=/dev/zero of=swapfile bs=1M count=2000 mkswap swapfile swapon swapfile chmod 600 swapfile echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab #cat /proc/meminfo free -m 

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.



回答3:

It's because your hosting is running out of memory, please check this tutorial https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04



回答4:

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?query=how+to+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...


回答5:

In case that, someone else meet with this issue. It might because the disk quote limit exceed.



回答6:

You can try setting preferred-install to "dist" in the WP CLI's Composer config - usually at ~/.wp-cli/packages/composer.json.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!