Where Does Composer Store Its Cache?
Where Composer keeps its home directory and package cache on each OS, and the two commands that reveal them.
Last updated
Composer splits state two ways: a home directory with config and auth (COMPOSER_HOME, defaulting to ~/.composer or ~/.config/composer on Unix and %APPDATA%\Composer on Windows) and a cache directory with downloaded zips and metadata (~/Library/Caches/composer on Mac, %LOCALAPPDATA%\Composer on Windows).
The classic confusion is $home meaning COMPOSER_HOME rather than your login home, which sends people to ~/cache instead of ~/.composer/cache. Run the config print commands once and the mystery ends permanently. Vendor folders inside projects are separate and never part of either directory.
Where Composer stores this, by platform
~/.cache/composer
XDG systems use $XDG_CACHE_HOME/composer and $XDG_CONFIG_HOME/composer; others use ~/.composer/cache. Override with COMPOSER_CACHE_DIR and COMPOSER_HOME. Subfolders files, repo and vcs split the cache by kind.
~/Library/Caches/composer
Home defaults to ~/.composer on macOS. Same composer config print commands and COMPOSER_* overrides as Linux.
%LOCALAPPDATA%\Composer
Paste %LOCALAPPDATA%\Composer into Explorer for the cache; home sits at %APPDATA%\Composer. Same overrides and clear-cache command.
Frequently asked questions
How do I print my exact Composer paths?
Run composer config --global home for the home dir and composer config --global cache-dir (or composer config -gl) for the cache. Trust that output over docs when COMPOSER_HOME or COMPOSER_CACHE_DIR is set, since env vars silently win.
How do I clean the Composer cache safely?
Run composer clear-cache. It empties files, repo and vcs caches while leaving installed vendor/ folders untouched. CI images do this routinely; local devs do it when a corrupt zip poisons installs.
Notice an outdated path? Let us know.