package-versions-deprecated: Could not delete /home/vagrant/.../vendor/composer/package-versions-deprecated/src

I am running into this issue attempting to upgrade to composer version 2. In a Laravel\Homestead vagrant box on Windows 10 with Virtual box.

PHP version: 7.2

composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.2",
        "ext-json": "*",
        "arcanedev/log-viewer": "^5.1",
        "asvae/laravel-api-tester": "^2.0",
        "aws/aws-sdk-php": "^3.101",
        "bepsvpt/secure-headers": "^5.3",
        "beyondcode/laravel-websockets": "^1.8",
        "doctrine/annotations": "^1.6",
        "doctrine/couchdb": "^1.0@beta",
        "doctrine/dbal": "^2.7",
        "fideloper/proxy": "^4.0",
        "firebase/php-jwt": "^5.0",
        "gluedev/laravel-stackdriver": "^0.1.2",
        "google/cloud": "^0.96.0",
        "google/protobuf": "^3.8",
        "graylog2/gelf-php": "^1.6",
        "hoa/console": "^3.17",
        "ircmaxell/random-lib": "^1.2",
        "kitetail/zttp": "^0.6.0",
        "ktamas77/firebase-php": "^2.2",
        "langleyfoxall/laravel-nist-password-rules": "^4.1",
        "laravel/framework": "6.18.22",
        "laravel/passport": "^9.3",
        "laravel/tinker": "^2.0",
        "laravel-notification-channels/twilio": "^3.1",
        "league/csv": "^9.1",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/flysystem-azure-blob-storage": "^0.1.6",
        "league/flysystem-cached-adapter": "^1.0",
        "league/flysystem-rackspace": "^1.0",
        "league/flysystem-sftp": "^1.0",
        "league/flysystem-webdav": "^1.0",
        "league/flysystem-ziparchive": "^1.0",
        "mockery/mockery": "^1.0",
        "mollie/polyfill-libsodium": "^1.1",
        "nexmo/client": "^1.8",
        "nyholm/psr7": "^1.1",
        "opencensus/opencensus-exporter-stackdriver": "~0.1",
        "pda/pheanstalk": "^4.0",
        "php-amqplib/php-amqplib": "^2.9",
        "php-console/php-console": "^3.1",
        "phpseclib/mcrypt_compat": "^1.0",
        "phpunit/php-invoker": "^2.0",
        "predis/predis": "^1.1",
        "propaganistas/laravel-intl": "^3.0",
        "propaganistas/laravel-phone": "^4.2",
        "psr/event-dispatcher": "^1.0",
        "ramsey/uuid-doctrine": "^1.5",
        "rbdwllr/reallysimplejwt": "^2.0.42",
        "rollbar/rollbar": "^1.8",
        "ruflin/elastica": "^6.1",
        "spatie/flysystem-dropbox": "^1.1",
        "spatie/laravel-fractal": "^5.6",
        "spatie/laravel-permission": "^3.6",
        "symfony/browser-kit": "^4.3",
        "symfony/config": "^4.3",
        "symfony/dependency-injection": "^4.3",
        "symfony/dom-crawler": "^4.3",
        "symfony/expression-language": "^4.3",
        "symfony/lock": "^4.3",
        "symfony/translation": "4.3.8",
        "symfony/yaml": "^4.3",
        "titasgailius/search-relations": "^1.0",
        "true/punycode": "^2.1",
        "twilio/sdk": "^6.10",
        "unicodeveloper/laravel-password": "1.0.*",
        "voiceit-php/voiceit2": "^3.0",
        "whoops/soap": "^1.0",
        "wildbit/swiftmailer-postmark": "^3.0"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.3",
        "beyondcode/laravel-er-diagram-generator": "^0.2.2",
        "coderello/laravel-populated-factory": "^0.3.0",
        "facade/ignition": "^1.16",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0",
        "squizlabs/php_codesniffer": "^3.3"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

and I get this as an output:

Executing command (CWD): rm -rf '/home/vagrant/<myAppDirectory>/vendor/wildbit/swiftmailer-postmark'                                                          
Downloading https://packagist.org/downloads/                                                                                                           
[201] https://packagist.org/downloads/                                                                                                                 
                                                                                                                                                       
                                                                                                                                                       
  [RuntimeException]                                                                                                                                   
  Could not delete /home/vagrant/<myAppDirectory>/vendor/composer/package-versions-deprecated/src:                                                            
                                                                                                                                                       
                                                                                                                                                       
Exception trace:                                                                                                                                       
 () at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:218                                                                             
 Composer\Util\Filesystem->unlink() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:171                                             
 Composer\Util\Filesystem->removeDirectoryPhp() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:138                                 
 Composer\Util\Filesystem->removeDirectory() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:378                          
 Composer\Downloader\FileDownloader->remove() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:349                        
 Composer\Downloader\DownloadManager->remove() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:299                       
 Composer\Installer\LibraryInstaller->removeCode() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:189                   
 Composer\Installer\LibraryInstaller->uninstall() at phar:///usr/local/bin/composer/src/Composer/Installer/PluginInstaller.php:121                     
 Composer\Installer\PluginInstaller->rollbackInstall() at phar:///usr/local/bin/composer/src/Composer/Installer/PluginInstaller.php:79                 
 Composer\Installer\PluginInstaller->Composer\Installer\{closure}() at n/a:n/a                                                                         
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20                                     
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:74                       
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166                                            
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95                       
 React\Promise\Deferred->resolve() at n/a:n/a                                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20                                     
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:78                       
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166                                            
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95                       
 React\Promise\Deferred->resolve() at n/a:n/a                                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20                                     
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:78                       
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166                                            
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95                       
 React\Promise\Deferred->resolve() at n/a:n/a                                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20                                     
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:78                       
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166                                            
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95                       
 React\Promise\Deferred->resolve() at n/a:n/a                                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20                                     
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:78                       
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a                                                                                          
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166                                            
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95                       
 React\Promise\Deferred->resolve() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Promise.php:42                             
 React\Promise\Promise->React\Promise\{closure}() at n/a:n/a                                                                                           
 call_user_func() at phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php:284                                                          
 Composer\Util\ProcessExecutor->countActiveJobs() at phar:///usr/local/bin/composer/src/Composer/Util/Loop.php:95                                      
 Composer\Util\Loop->wait() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:454                                       
 Composer\Installer\InstallationManager->waitOnPromises() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:440         
 Composer\Installer\InstallationManager->executeBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:367           
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:266
 Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:696                                    
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:533                                                      
 Composer\Installer->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Installer.php:245                                                       
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:231                                                
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245                            
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835                         
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185                    
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:310                             
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117                                    
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:122                               
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:63                                                                 
 require() at /usr/local/bin/composer:24    

I am not sure how to fix it. I can get around it by running composer --no-plugins. However, I am not sure that I actually want to do that.

Any help would be much appreciated.

– Thanks

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 23 (7 by maintainers)

Most upvoted comments

I am also encountering this same issue with installing this package in a Laravel/Vagrant environment using Composer 2.0.8 and php 7.3.

Ok yeah from that what it looks like is:

  • Package gets installed via a new unzip process

  • PHP process sees it’s done, tries to enable the plugin

  • Enabling plugin looks up the plugin class, and tries to autoload it, but that fails to be read:

    Plugin installation failed (include(/home/vagrant/medsitter/vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php): failed to open stream: No such file or directory), rolling back

    This is seemingly because the filesystem writes from the unzip process aren’t fully synced yet / not yet accessible.

  • It then assumes it needs to rollback the install to avoid ending up in a bad state with a bad plugin, and tries deleting the plugin dir

  • Deleting the plugin dir fails too without any error message (note the : ending then nothing) which is odd but probably also due to some underlying filesystem problem.

    [RuntimeException] Could not delete /home/vagrant/medsitter/vendor/composer/package-versions-deprecated/src/PackageVersions:

I think we could try to workaround this in the PluginManager::registerPackage by detecting the issue, sleeping for a bit and trying again to see if the file magically appeared. If you can install composer from source and try that that’d be great, otherwise I’ll try to have a go at it sometime I guess.

Just ran into this one on:

Vagrant version: 2.2.14
Virtualbox version: 6.1.16 
GuestAdditions version: 6.1.16
Composer version: 2.0.7
PHP version: 7.4.13
Virtual machine: Linux debian-buster64 4.19.0-8-amd64
Host machine: MacOs 11.0.1

I believe there is quite some history behind this particular issue, just posting some references here because this keeps coming back like a zombie from Walking Dead.

https://www.virtualbox.org/ticket/18776#comment:5 https://github.com/laravel/homestead/issues/1240

I can confirm that downgrading to composer v1 does… let’s say… make the problem less likely to occur (to prevent saying “fixes it”). It also only occures on the shared folder, running fully inside the VM works fine.

Thank you very much! Appreciate your time.

Possibly because Composer 2 runs unzips in parallel, or possibly because it just does different things post-install than v1 did. I am not entirely sure. It’d be great to get a full composer update -vvv output. Perhaps that’d highlight something.