skip to Main Content

The package symfony/finder is a transitive dependency in my app. I’ve tried to do composer update and got this output:

user@host:/var/www$ composer update && composer check
Loading composer repositories with package information
Updating dependencies (including require-dev)         
Package operations: 0 installs, 51 updates, 0 removals
  - Updating symfony/finder (v5.1.0 => v5.1.2): 
In ClassLoader.php line 444:

  [ErrorException]                                                                                                                       
  include(/var/www/vendor/composer/../symfony/finder/Comparator/NumberComparator.php): failed to open stream: No such file or directory  


Exception trace:
  at /var/www/vendor/composer/ClassLoader.php:444
 ComposerUtilErrorHandler::handle() at /var/www/vendor/composer/ClassLoader.php:444
 include() at /var/www/vendor/composer/ClassLoader.php:444
 ComposerAutoloadincludeFile() at /var/www/vendor/composer/ClassLoader.php:322
 ComposerAutoloadClassLoader->loadClass() at n/a:n/a
 spl_autoload_call() at /var/www/vendor/symfony/finder/Finder.php:125
 SymfonyComponentFinderFinder->depth() at /var/www/vendor/composer/composer/src/Composer/Util/Filesystem.php:77
 ComposerUtilFilesystem->emptyDirectory() at /var/www/vendor/composer/composer/src/Composer/Downloader/FileDownloader.php:123
 ComposerDownloaderFileDownloader->doDownload() at /var/www/vendor/composer/composer/src/Composer/Downloader/FileDownloader.php:97
 ComposerDownloaderFileDownloader->download() at /var/www/vendor/composer/composer/src/Composer/Downloader/ArchiveDownloader.php:38
 ComposerDownloaderArchiveDownloader->download() at /var/www/vendor/composer/composer/src/Composer/Downloader/ZipDownloader.php:77
 ComposerDownloaderZipDownloader->download() at /var/www/vendor/composer/composer/src/Composer/Downloader/FileDownloader.php:225
 ComposerDownloaderFileDownloader->update() at /var/www/vendor/composer/composer/src/Composer/Downloader/DownloadManager.php:271
 ComposerDownloaderDownloadManager->update() at /var/www/vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php:218
 ComposerInstallerLibraryInstaller->updateCode() at /var/www/vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php:120
 ComposerInstallerLibraryInstaller->update() at /var/www/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:193
 ComposerInstallerInstallationManager->update() at /var/www/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:160
 ComposerInstallerInstallationManager->execute() at /var/www/vendor/composer/composer/src/Composer/Installer.php:611
 ComposerInstaller->doInstall() at /var/www/vendor/composer/composer/src/Composer/Installer.php:232
 ComposerInstaller->run() at /var/www/vendor/composer/composer/src/Composer/Command/UpdateCommand.php:163
 ComposerCommandUpdateCommand->execute() at /var/www/vendor/symfony/console/Command/Command.php:258
 SymfonyComponentConsoleCommandCommand->run() at /var/www/vendor/symfony/console/Application.php:911
 SymfonyComponentConsoleApplication->doRunCommand() at /var/www/vendor/symfony/console/Application.php:264
 SymfonyComponentConsoleApplication->doRun() at /var/www/vendor/composer/composer/src/Composer/Console/Application.php:281
 ComposerConsoleApplication->doRun() at /var/www/vendor/symfony/console/Application.php:140
 SymfonyComponentConsoleApplication->run() at /var/www/vendor/composer/composer/src/Composer/Console/Application.php:113
 ComposerConsoleApplication->run() at /var/www/vendor/composer/composer/bin/composer:62

I’ve checked and it turned out that directory /var/www/vendor//symfony/finder is just completely empty. I’ve tried updating to 5.1.1 and the result was the same. Running composer dump didn’t help either.

So I had to add symfony/finder 5.1.0 as a dependency in my app to keep Composer working. And it helped – every other package updated without a hitch.

I’m not familiar with the Symfony ecosystem and don’t know where to look for solutions: search results came up empty and the issues functionality is disabled at https://github.com/symfony/finder.

I’m running Composer 1.10.7 inside a Docker container.
Here is what composer.json looks like:

{
    "name": "name",
    "type": "project",
    "description": "",
    "license": "proprietary",
    "require": {
        "php": "^7.4.3",
        "ext-decimal": "^1.1",
        "ext-dom": "*",
        "ext-ftp": "*",
        "ext-intl": "*",
        "ext-json": "*",
        "ext-libxml": "*",
        "ext-pdo": "*",
        "ext-redis": "*",
        "ext-simplexml": "*",
        "ext-sync": "*",
        "ext-xhprof": "^2.2",
        "ext-xml": "*",
        "ext-zip": "*",
        "alhimik1986/php-excel-templator": "^1.0",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.0",
        "laravel/horizon": "^4.3",
        "laravel/telescope": "^3.2",
        "laravel/tinker": "^2.0",
        "pbweb/xhprof": "^1.0",
        "php-decimal/laravel": "^1.1",
        "php-decimal/php-decimal": "^1.1",
        "phpoffice/phpexcel": "^1.8",
        "phpoffice/phpspreadsheet": "1.12.*",
        "propaganistas/laravel-phone": "^4.2",
        "webmozart/assert": "^1.8"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.3",
        "barryvdh/laravel-ide-helper": "^2.7",
        "doctrine/dbal": "~2.10",
        "facade/ignition": "^2.0",
        "friendsofphp/php-cs-fixer": "^2.16",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "nunomaduro/larastan": "^0.6",
        "phpstan/phpstan": "^0.12",
        "phpunit/phpunit": "^9.1",
        "rector/rector": "^0.7",
        "roave/security-advisories": "dev-master",
        "sebastian/phpcpd": "^5.0",
        "squizlabs/php_codesniffer": "^3.5",
        "timacdonald/log-fake": "^1.6"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "process-timeout": 0
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "files": [
            "app/Helpers/system.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "cs": [
            "./vendor/bin/phpcs --standard=./config/tools/phpcs.xml ./app/ ./tests/"
        ],
        "cs-fix": [
            "php vendor/bin/php-cs-fixer fix"
        ],
        "cpd": [
            "./vendor/bin/phpcpd ./app/ ./resources/views/"
        ],
        "phpstan": [
            "./vendor/bin/phpstan analyse -c /var/www/config/tools/phpstan.neon"
        ],
        "churn": [
            "./vendor/bin/churn run -c ./config/tools/churn.yml ./app/ ./tests/"
        ],
        "check": [
            "./check-code-health.sh"
        ],
        "test:features": [
            "composer test -- --testsuite Feature"
        ],
        "test:features:verbose": [
            "composer test:verbose -- --testsuite Feature"
        ],
        "test:unit": [
            "composer test -- --testsuite Unit"
        ],
        "test:unit:verbose": [
            "composer test:verbose -- --testsuite Unit"
        ],
        "test:unit:coverage": [
            "composer test:coverage -- --testsuite Unit"
        ],
        "test:verbose": [
            "./vendor/bin/phpunit --configuration=./config/tools/phpunit.xml --do-not-cache-result --colors=always --testdox --verbose"
        ],
        "test:coverage": [
            "composer test -- --coverage-html=./storage/coverage"
        ],
        "test": [
            "./vendor/bin/phpunit --configuration=./config/tools/phpunit.xml --do-not-cache-result --colors=always"
        ]
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    The problem turned out to be with invalid $PATH. I've had export PATH="/var/www/vendor/bin:$PATH" in ~/.bashrc, so composer update was using composer inside a vendor directory which was being updated.

    Running php composer.phar update solved the problem since phar has it's dependencies (namely symfony/finder) bundled inside.


  2. In addition to the php composer.phar update solution already mentioned, another option is to put vendor/bin at the end of $PATH rather than at the front.

    If vendor/bin is at the front of $PATH, composer might run from a local installation if you have a package like nunomaduro/larastan that depends on it. Upgrades to seemingly-unrelated packages like symfony/finder will then fail with references to missing files because they’ve been deleted as part of the normal upgrade process which also happened to break that local composer installation that you may not have realized you were using in the first place.

    If vendor/bin is at the end of $PATH, all that is avoided and you still have access to project-specific executables in vendor/bin. That should work as long as you’re not relying on vendor/bin to overshadow things in other places.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search