protected function defaultCacheDir()
    {
        $cacheDir = getenv('COMPOSER_CACHE_DIR');
        if ($cacheDir) {
            return $cacheDir;
        }

        $home = getenv('COMPOSER_HOME');
        $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR');

        if (!$home) {
            if ($isWindows) {
                if ($envAppData = getenv('APPDATA')) {
                    $home = strtr($envAppData, '\\', '/') . '/Composer';
                }
            } elseif ($envHome = getenv('HOME')) {
                $home = rtrim($envHome, '/') . '/.composer';
            }
        }

        if ($home && !$cacheDir) {
            if ($isWindows) {
                if ($cacheDir = getenv('LOCALAPPDATA')) {
                    $cacheDir .= '/Composer';
                } else {
                    $cacheDir = $home . '/cache';
                }

                $cacheDir = strtr($cacheDir, '\\', '/');
            } else {
                $cacheDir = $home . '/cache';
            }
        }

        if (!$cacheDir) {
            return null;
        }

        return $cacheDir;
    }