Composer Memory Issue: proc_open(): fork failed - Cannot allocate memory
I rebuilt my
arandomproject server, in favor of this one, but this worked on that server just fine. As far as I know it is setup the exact same way.
When I run this command, in /var/www/:
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition arandomproject
I get the following messages including the following error:
Installing magento/project-community-edition (2.3.2) - Installing magento/project-community-edition (2.3.2): Loading from cache Created project in arandomproject Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 422 installs, 0 updates, 0 removals - Installing magento/magento-composer-installer (0.1.13): Loading from cache proc_open(): fork failed - Cannot allocate memory The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems) Unzip with unzip command failed, falling back to ZipArchive class 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:///usr/bin/composer/vendor/symfony/console/Application.php on line 952 Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/bin/composer/vendor/symfony/console/Application.php on line 952 [ErrorException] proc_open(): fork failed - Cannot allocate memory
ErrorException you're seeing means that there's simply not enough memory available to run the job on your Linode. There's another Community post with regards to a Symfony Compose job, that explains a Nanode is usually insufficient for running this, as the required memory for this job and anything else on the server usually will be too much on the Linode. In that case, it was determined that a 2GB Linode was the minimum needed for that job.
If you can determine that the size of the Linode plan you're using isn't sufficient, you can resize your Linode at any time. This can be helpful with testing out the available memory needed for the job.
We have a post that lists a few tools you can use to gauge the memory use on your Linode that may be helpful in determining if it is memory related specifically. Additionally, there's a section in Composer's documentation related to this very error.
You mentioned that this is on a rebuilt server, but it worked on the previous server. Is it possible that there's more running on this server? If not, then it may be something else.
I also found this very informative post on StackOverflow, which has a number of possible steps you can take to fix this issue. Some of the suggestions in that post include:
- Upgrading PHP version
- Reallocating additional swap
- Remove vendor directory to not build from cache
Reviewing the options, I'd personally opt for resizing the Linode, as this could take a few moments of time to determine if the additional resources were all that was needed.