How to fix the composer update failure asking you to update a package and unable to remove it ?

Julien Balmont
Zenchef’s Tech and Product Blog
2 min readDec 27, 2016

From time to time, when you try to update you dependencies using

composer update

You might be asked the following annoying question

Would you like to try reinstalling the package instead [yes]?

In this case, whether you answer yes or no, the command line just doesn’t matter and fails.
For example:

Dependency resolution completed in 0.005 seconds
— Removing guzzlehttp/promises (1.2.0)
Update failed (Could not delete vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php: )
Would you like to try reinstalling the package instead [yes]? yes
[RuntimeException]
Could not delete vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php…

The answer is as simple as deleting the offending package from your vendor folder (here, guzzlehttp), and cleaning the composer cache

rm -rf vendor/guzzlehttp

composer clearcache

Try again your composer update

If it’s still complaining, it means that you might have a permission issue (probably because at some point you ran a composer update in sudo mode or made a modification directly in your vendor directlory).

The easiest solution is to remove your vendor directory and install from scratch all your dependencies

rm -rf vendor
composer install -vvv

It should work now :) Enjoy your code !
Thanks Alex Lombry For the solution :p

Edit: Thanks to the reddit user “xroni” for the comment, the article has been updated consequently.

--

--