Composer loading from cache

PhpComposer Php

Php Problem Overview


i ran in a problem using composer for installing/uninstalling some dependencies in laravel which coming back after deleting them from composer.json and deleting their vendor folder, i initially used dflydev's markdown package but now i wanted to change it to michelf's php-markdown, but i cant uninstall the old one since it comes back loaded from cache, which i checked at AppData\Roaming\Composer and is empty, any clue on to why this is happening?

  - Installing dflydev/markdown (dev-master dee1f7a)
    Loading from cache

Php Solutions


Solution 1 - Php

You can use the following command to clear the cache irrespective of the OS you are on:

php composer.phar clear-cache

or if composer is installed globally

composer clear-cache

Solution 2 - Php

I think, you can run your composer commands with --no-cache option flag like

composer install --no-cache

Or

composer require <package-name> --no-cache

Or

composer update [<package-name>] --no-cache

Solution 3 - Php

If you want to clear all packages cache, please try following:

$ composer clearcache

Or to just clear one or a few packages:

$ composer clearcache packagename1 packagename2 ...

You can also use clear-cache which is an alias for clearcache.

Source : https://blog.liplex.de/clear-composer-cache/

Solution 4 - Php

composer caches packages under vendor/packagename convention. So you shouldn't run into any issue, just because the packagename is used in another vendor's package.

the cache locations are:

  • Windows: %LOCALAPPDATA%\Composer\files\vendor\packagename
  • Linux: ~/.composer/cache/files/vendor/packagename
  • Mac OS: ~/.composer/cache/files/packagename

Solution 5 - Php

In some cases (for example OpenSuse 42.1) all user cache are puts in:

~/.cache/

For the composer, the same as other applications, the cache path is:

~/.cache/composer/

So, just remove this folder as follow:

rm -fR ~/.cache/composer

Solution 6 - Php

Don't edit your composer.json file manually to remove a package - it will remain in composer.lock.

Use composer remove to delete the old package then composer require to install the replacement.

Solution 7 - Php

run the following command

rm -rf ~/.composer/cache*

if Permission denied add sudo

Solution 8 - Php

On Window, I see the composer cache file located in
C:\Users\{your_user}\AppData\Local\Composer\files

enter image description here

It stores ZIP files. The below image has 2 Zip files because I have downloaded 2 versions of monolog (1.0.1 and 1.0.2) enter image description here

To remove the cache, simply delete the Zip file or folder.

Solution 9 - Php

So the only thing that worked for me on my Macbook was removing the package from my composer.json, deleting my composer.lock, running composer update, then adding the package back to composer.json, deleting my composer.lock(again), and running composer update (again). I had a local package in my instance of Laravel Nova that I changed to all lowercase from CamelCase and no matter what I did, it kept adding the package with the old CamelCase name. Didn't matter if I cleared caches or anything.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTarikView Question on Stackoverflow
Solution 1 - PhpAtish GoswamiView Answer on Stackoverflow
Solution 2 - PhpSyed Abidur RahmanView Answer on Stackoverflow
Solution 3 - Phpmonsur.hoqView Answer on Stackoverflow
Solution 4 - PhpSimon WickiView Answer on Stackoverflow
Solution 5 - PhpMostafaView Answer on Stackoverflow
Solution 6 - PhpDarvanenView Answer on Stackoverflow
Solution 7 - PhpSir MbukiView Answer on Stackoverflow
Solution 8 - PhpLinhView Answer on Stackoverflow
Solution 9 - PhpsamnauView Answer on Stackoverflow