DEV Community


Posted on

Composer install error Failed to extract

Yesterday I updated a CakePHP app as I routinely do and a strange error popup-ed in the composer install stage of my docker build:

Failed to extract wyrihaximus/twig-view: (9) unzip -qq  '/var/www/html/vendor/composer/tmp-d8e7d258ae112df88e50fadda2ad540d' -d '/var/www/html/vendor/composer/c379dd11'

unzip:  cannot find or open /var/www/html/vendor/composer/tmp-d8e7d258ae112df88e50fadda2ad540d.

    This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
    See for an example fix
    Failed to extract cakephp/bake: (9) unzip -qq  '/var/www/html/vendor/composer/tmp-0ea29ff25d5dad521623339cec9bf3bb' -d '/var/www/html/vendor/composer/cc137293'
Enter fullscreen mode Exit fullscreen mode

The same happened with cakephp/debug_kit, cakephp/migrations, cakephp/bake and josegonzalez/cakephp-upload dependencies.

After researching and testing I realized Composer had updated to version 2 a couple of days ago and in my Dockerfile I installed it with the command:
RUN curl -sS | php -- --install-dir=/usr/bin --filename=composer

Clearly this brought Coposer's latest version and broke some dependencies. The solution was to freeze Composer's version download to 1.x:
RUN curl -sS -o composer.phar

Doing this also required me to run php composer.phar install instead of composer install.

And done, the app was good and running once again!

Top comments (3)

elte156 profile image
Tony Pagaduan

Thanks for this. I am in the same situation with my Dockerfile.
Instead of downloading the phar file, you can still install the binary so you can keep using composer install.

php composer-setup.php --quiet
php composer-setup.php --quiet --filename=composer --version=1.10.19

urielbitton profile image
Uriel Bitton

Nice one Tony.
Welcome to DEV as well!

guillecro profile image
Guillermo Croppi

You are my hero