I'm getting errors updating a site with composer. I've updated a lot of times this site with a simple "composer update", but this time I'm getting a php error.

Curiously "composer update --dry-run" does not produce any error:

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 6 updates, 0 removals
  - Upgrading symfony/finder (v4.4.27 => v4.4.30)
  - Upgrading symfony/phpunit-bridge (v5.3.4 => v5.3.7)
  - Upgrading symfony/dom-crawler (v4.4.27 => v4.4.30)
  - Upgrading phpunit/phpunit (9.5.8 => 9.5.9)
  - Upgrading drupal/spambot (1.0.0 => 1.2.0)
  - Upgrading phpstan/phpstan (0.12.96 => 0.12.98)
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package sebastian/resource-operations is abandoned, you should avoid using it. No replacement was suggested.
85 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

But "composer update" fails:

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 6 updates, 0 removals
  - Upgrading symfony/finder (v4.4.27 => v4.4.30): Extracting archive
    Update of symfony/phpunit-bridge failed
  - Upgrading symfony/dom-crawler (v4.4.27 => v4.4.30): Extracting archive
    Update of phpunit/phpunit failed
  - Upgrading drupal/spambot (1.0.0 => 1.2.0): Extracting archive
    Update of phpstan/phpstan failed
    Update of symfony/finder failed
 0/2 [>---------------------------]   0%    Update of symfony/dom-crawler failed
    Update of drupal/spambot failed
 2/2 [============================] 100%PHP Fatal error:  Uncaught Error: Class 'Symfony\Component\Finder\Finder' not found in /data/ubuntucat/vendor/composer/composer/src/Composer/Util/Filesystem.php:56
Stack trace:
#0 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/BinaryInstaller.php(121): Composer\Util\Filesystem->isDirEmpty()
#1 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php(162): Composer\Installer\BinaryInstaller->removeBinaries()
#2 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(504): Composer\Installer\LibraryInstaller->update()
#3 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(418): Composer\Installer\InstallationManager->update()
#4 /data/ubuntucat/vendor/react/promise/src/FulfilledPromise.php(28): Composer\Installer\InstallationManager->Composer\Installer\{closure}()
#5 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(419): React\Promise\FulfilledPromise->then()
#6 /data/ubuntucat/v in /data/ubuntucat/vendor/composer/composer/src/Composer/Util/Filesystem.php on line 56

Fatal error: Uncaught Error: Class 'Symfony\Component\Finder\Finder' not found in /data/ubuntucat/vendor/composer/composer/src/Composer/Util/Filesystem.php:56
Stack trace:
#0 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/BinaryInstaller.php(121): Composer\Util\Filesystem->isDirEmpty()
#1 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php(162): Composer\Installer\BinaryInstaller->removeBinaries()
#2 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(504): Composer\Installer\LibraryInstaller->update()
#3 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(418): Composer\Installer\InstallationManager->update()
#4 /data/ubuntucat/vendor/react/promise/src/FulfilledPromise.php(28): Composer\Installer\InstallationManager->Composer\Installer\{closure}()
#5 /data/ubuntucat/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(419): React\Promise\FulfilledPromise->then()
#6 /data/ubuntucat/v in /data/ubuntucat/vendor/composer/composer/src/Composer/Util/Filesystem.php on line 56

This is a pastebin of my composer.json:

https://pastebin.ubuntu.com/p/Q2GwXzSgpW/

Comments

wagafo’s picture

I solved this problem after a lot of searching. It seems that doing this update using the composer in vendor/bin tries to update symfony/finder, it erases all the content of this directory, and then it complains that it cannot find a function which is defined there. The solution for me was to do a "php composer.phar update". It seems composer.phar has all the libraries inside and so it completes the update.

This is the source that gave me this idea:

https://stackoverflow.com/questions/62423697/unable-to-update-symfony-fi...