1
0
Fork 0

Throw exception if HOME or APPDATA is not available to create the composer home dir

pull/1781/head
Jordi Boggiano 2013-04-07 17:14:53 +02:00
parent 3ce71466f1
commit e8c362c273
1 changed files with 6 additions and 0 deletions

View File

@ -43,8 +43,14 @@ class Factory
$cacheDir = getenv('COMPOSER_CACHE_DIR'); $cacheDir = getenv('COMPOSER_CACHE_DIR');
if (!$home) { if (!$home) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (!getenv('APPDATA')) {
throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
}
$home = strtr(getenv('APPDATA'), '\\', '/') . '/Composer'; $home = strtr(getenv('APPDATA'), '\\', '/') . '/Composer';
} else { } else {
if (!getenv('HOME')) {
throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
}
$home = rtrim(getenv('HOME'), '/') . '/.composer'; $home = rtrim(getenv('HOME'), '/') . '/.composer';
} }
} }