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

Composer - PHP Warning: proc_open(): fork failed - Cannot allocate memory

我对 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

我看到还有其他几个问题与此问题类似,但其中 none 提出了修复错误的解决方案

@arno 我今天也开始遇到这种情况,运行 composer require。我按照作曲家提供的步骤更新了我的交换文件。这对我有用。

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

COMPOSER_MEMORY_LIMIT=-1 composer update

那个小小的额外命令在我的旧服务器上救了我的命。