How To Clear Composer Cache

How To Clear Composer Cache

Provides all the steps required to clear composer cache on both Windows and Ubuntu.

March 24, 2019

Sometimes we get an error message while updating the composer as shown below.

The requested package vendor/package could not be found in any version, there may be a typo in the package name

OR

The requested package bower-asset/package could not be found in any version, there may be a typo in the package name.

Most of the time, this error message goes away after completely cleaning the composer cache. This tutorial assumes that the composer is installed globally on both Windows and Ubuntu.

Windows

The below mentioned commands can be used to clear composer cache on windows.

// Check Version
composer --version

// It should show the version like
Composer version 1.5.2 2017-09-11 16:59:25


// Clear the cache
composer clearcache

// It will show the messages as shown below
Clearing cache (cache-vcs-dir): C:\Users\user1\AppData\Local\Composer\vcs
Clearing cache (cache-repo-dir): C:\Users\user1\AppData\Local\Composer\repo
Clearing cache (cache-files-dir): C:\Users\user1\AppData\Local\Composer\files
Clearing cache (cache-dir): C:\Users\user1\AppData\Local\Composer
All caches cleared.

After running this command, the Composer directory located within the local app data directory will be removed completely. If we run the composer install or update command, it will take some time to get all the dependencies for the first time.

Ubuntu

Use below-mentioned commands to clear the composer cache completely. The same commands should work fine for other versions of Linux.

// Clear cache
composer clearcache
// OR
composer clear-cache

// Completely remove the cache directory
sudo rm -rf ~/.composer

Now if we run composer update command, the error won't be displayed and the dependencies get installed.

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS