diff --git a/doc/06-config.md b/doc/06-config.md index ad350e850..bca15316d 100644 --- a/doc/06-config.md +++ b/doc/06-config.md @@ -213,9 +213,10 @@ versions. See also [COMPOSER_HOME](03-cli.md#composer-home). ## cache-dir Defaults to `C:\Users\\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](03-cli.md#composer-home). +`/Users//Library/Caches/composer` on macOS, `$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](03-cli.md#composer-home). ## cache-files-dir diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index cd6662c30..aa89f0cf8 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -121,6 +121,15 @@ class Factory } $userDir = self::getUserDir(); + if (PHP_OS === 'Darwin') { + // Migrate existing cache dir in old location if present + if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) { + Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer'); + } + + return $userDir . '/Library/Caches/composer'; + } + if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) { return $home . '/cache'; }