Composer install error Failed to extract

franzka profile image Franz ・1 min read

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 https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb 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 https://getcomposer.org/installer | 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 https://getcomposer.org/composer-1.phar -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!


Editor guide
guillecro profile image
Guillermo Croppi

You are my hero