arthurvillar's avatar

Composer won't run update: memory exhausted

Hello!

Composer is failing every time I run "composer update", regardless if I use --no-dev or not. This also means it also fails when I install new packages with "composer require [package]".

This is happening on my local machine and now I am afraid of updating the live server and create issues there.

Here is one output:

composer update --no-dev
    1/5:        http://repo.packagist.org/p/provider-201312fd0231b323cf89aac8a4b571485468fad4974d6f1b438c1199119c894a51.json
    2/5:        http://repo.packagist.org/p/provider-2014$b3109a33253fa386440f4695e7b315f9ff6652058ff082760efc31e1d9f6b312.json
    3/5:        http://repo.packagist.org/p/provider-2020-1007660de1dcf6594845d0aaf5dcbe51a62022878360a094bc52814584d0972b.json
    4/5:        http://repo.packagist.org/p/provider-latest6a0484cb6fbb4de15978e2f5d2fa1ef60e82dc6b0e6c7840b25f1d2545ecdf.json
    5/5:        http://repo.packagist.org/p/provider-2018$e200f2c6a6178d2cc80f34b8a6fcc4ff4249e1e172a4a46e111b25f45035c990.json
    Finished: success: 5, skipped: 0, failure: 0, total: 5
Loading composer repositories with package information
Updating dependencies

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 83

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 83

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

Any ideas on what is going on?

If I set memory_limit to -1, the update ends with "killed".

Thanks!

0 likes
9 replies
tykus's avatar
tykus
Best Answer
Level 104

If you have not already, upgrade composer to v2 - many of these out-of-memory issues are immediately resolved.

1 like
arthurvillar's avatar

Oh my, I can't believe this was all. I just upgraded to v 2, it took a second and all is working now. Thank you so much!!

piljac1's avatar

I don't know if you meant that you set your php.ini memory_limit to -1 or composer's. If you meant that you tried setting it in your php.ini and not composer, you can prefix your command by COMPOSER_MEMORY_LIMIT=-1 which removes the memory limit for the current command. It always does the trick for me.

For example

COMPOSER_MEMORY_LIMIT=-1 composer update

Normally, it is the same as setting it in your php.ini directly, but for some reason, your changes might have not been picked up (i.e. you didn't restart your php service).

arthurvillar's avatar

When I set the memory limit to -1 it made the command end with a "killed" message. It turns out that upgrading composer to v2 solved the issue. Thank you so much for the suggestion though!

tykus's avatar

It always does the trick for me.

Are you experiencing memory issues with Composer v2 @piljac1 ; or are you still on v1?

piljac1's avatar

Still on 1 at the moment because our main project is still running on older packages that are not compatible with composer 2. We're set to upgrade everything in a sprint or 2 (including a Laravel 6 to 8 upgrade).

Snapey's avatar

you should be ok to delete the vendor folder and composer.lock then run composer install

arthurvillar's avatar

I did that but to no avail. It turns out that upgrading to v2 did the trick!

Please or to participate in this conversation.