Composer-PHP警告:proc_open():fork失败-无法分配内存

时间:2019-06-24 08:01:38

标签: memory composer-php fork proc-open

我在 composer 上遇到问题,它一直都能正常运行,但现在却不想...
这是一个简单的composer install命令的结果:

bob@SRV04:~/testdir$ composer install
Loading composer repositories with package information
Updating dependencies
Package operations: 44 installs, 0 updates, 0 removals
  - Installing psr/container (1.0.0): The following exception is caused by a 
lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open- 
fork-failed-errors for details

PHP Warning:  proc_open(): fork failed - Cannot allocate memory in 
phar:///bin/composer/vendor/symfony/console/Application.php on line 952

Warning: proc_open(): fork failed - Cannot allocate memory in 
phar:///bin/composer/vendor/symfony/console/Application.php on line 952

[ErrorException]
proc_open(): fork failed - Cannot allocate memory

问题是,鉴于我的记忆状态,一切都会正常工作

free -h
             total       used       free     shared    buffers     cached
Mem:          7,8G       3,4G       4,4G       131M       207M       503M
-/+ buffers/cache:       2,7G       5,1G
Swap:         1,7G       728M       971M
  • 我更新了所有可以更新的内容
  • php.ini内存设置为-1

我看到还有其他一些类似的问题,但是没有一个提出解决错误的解决方案

2 个答案:

答案 0 :(得分:6)

COMPOSER_MEMORY_LIMIT=-1 composer update

那条额外的命令拯救了我在旧服务器上的生命。

答案 1 :(得分:0)

@arno这在我今天也开始发生,需要运行作曲家。我遵循了作曲家提供的步骤并更新了我的交换文件。这对我有用。

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04