longestdrive's avatar

Composer issues removing a package with Sail/Docker

I'm having issues trying to remove a package from my composer.json. No matter what I try the package persists despite it no longer featuring in composer.json and it appears to persist in composer.lock despite deleting composer.lock and getting composer to rebuild.

I'm using sail/docker as my development machine

I'm trying to remove: laravelcollective/html - due to warnings of it being no longer supported.

I've tried:

  1. deleting the entry from composer.json then run composer update - it still appears when dump-autoload is being run - but no entry for it in composer.json
  2. using the command composer remove laravelcollective/html - again entry removed from composer.json but still appears to be in stalled following dump-autoload
  3. deleting the vendor directory and then running composer install - still persists

I can't work out how to remove this package and have composer.lock reflect the changes and ensure dump-autoload works as expected.

I've also cleared the cache and config of laravel - no change

Are there any other caches or composer caches I should remove?

Should I try rebuilding docker?

Any suggestions appreciated

Thank you

0 likes
3 replies
LaryAI's avatar
Level 58

When dealing with Composer issues in a Docker environment like Laravel Sail, there are a few steps you can take to ensure that a package is completely removed. Here's a step-by-step guide to help you resolve the issue:

  1. Ensure the Package is Removed from composer.json: Make sure that the package laravelcollective/html is completely removed from your composer.json file. Double-check both the require and require-dev sections.

  2. Remove the Package Using Composer: Run the following command to remove the package. This should update both composer.json and composer.lock:

    ./vendor/bin/sail composer remove laravelcollective/html
    
  3. Clear Composer Cache: Sometimes, Composer's cache can cause issues. Clear the cache with:

    ./vendor/bin/sail composer clear-cache
    
  4. Delete the vendor Directory and composer.lock: Manually delete the vendor directory and the composer.lock file to ensure a fresh start:

    rm -rf vendor composer.lock
    
  5. Rebuild Docker Containers: Rebuilding your Docker containers can help ensure that there are no lingering dependencies:

    ./vendor/bin/sail down
    ./vendor/bin/sail build --no-cache
    ./vendor/bin/sail up -d
    
  6. Reinstall Dependencies: After rebuilding, reinstall your dependencies:

    ./vendor/bin/sail composer install
    
  7. Verify the Removal: Check the composer.lock file to ensure that laravelcollective/html is no longer listed. Also, verify that the package is not present in the vendor directory.

By following these steps, you should be able to completely remove the package from your Laravel Sail/Docker environment. If the issue persists, ensure that there are no other packages that might be requiring laravelcollective/html as a dependency.

Snapey's avatar
Snapey
Best Answer
Level 122

packages can be required by other packages.

You can run composer why vendor/packagename

for example;

$ composer why dompdf/dompdf
barryvdh/laravel-dompdf v2.2.0 requires dompdf/dompdf (^2.0.7) 
longestdrive's avatar

Thank you - that helped and I was able to track down a couple of packages that had the same dependency and resolved :)

Please or to participate in this conversation.