Reputation: 33921
https://getcomposer.org/doc/06-config.md#cache-dir
Is there a way I can verify which paths it is actually using?
And secondly the documentation does not seem valid - I don't have any ~/cache
directory OR $XDG_CACHE_HOME/composer
...
Upvotes: 8
Views: 4590
Reputation: 39169
If you are looking for your global composer configuration you can use the config
command:
composer config --global --list
Sample output form my docker container:
$ composer config --global --list | grep cache
[cache-dir] /tmp/cache
[cache-files-dir] {$cache-dir}/files (/tmp/cache/files)
[cache-repo-dir] {$cache-dir}/repo (/tmp/cache/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/tmp/cache/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
You might have missed the last part of the documentation, though:
cache-dir
Defaults to
C:\Users\<user>\AppData\Local\Composer
on Windows,$XDG_CACHE_HOME/composer
on unix systems that follow the XDG Base Directory Specifications, and$home/cache
on other unix systems. Stores all the caches used by Composer. See also COMPOSER_HOME.
Source: https://getcomposer.org/doc/06-config.md#cache-dir, emphasis mine.
So I think, here you missred $home/cache
to be ~/cache
when it is actually $COMPOSER_HOME/cache
From my docker container still, which confirm the /tmp/cache
folder raised by the config command:
$ echo $XDG_CACHE_HOME
$ echo $home
$ echo $COMPOSER_HOME
/tmp
So, in short, if set, the $COMPOSER_HOME
takes the precedence:
$ echo $COMPOSER_HOME
/tmp
$ unset COMPOSER_HOME
$ echo $COMOPSER_HOME
$ composer config -gl | grep 'cache-dir'
[cache-dir] /root/.composer/cache
[cache-files-dir] {$cache-dir}/files (/root/.composer/cache/files)
[cache-repo-dir] {$cache-dir}/repo (/root/.composer/cache/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/root/.composer/cache/vcs)
$ echo $HOME
/root
$ whoami
root
As you can see here, after unsetting $COMPOSER_HOME
, I end up with the home of my user (root here, which would be a bad practice for composer but I am on docker, for the demo).
So what you should read in
By default it points to (...) /home/<user>/.composer
Source: https://getcomposer.org/doc/03-cli.md#composer-home
Is
By default, when the variable is not set, it points to (...) /home/<user>/.composer
Upvotes: 13