From e8c362c2731a72d1992bec53ae753f4a27906175 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 Apr 2013 17:14:53 +0200 Subject: [PATCH] Throw exception if HOME or APPDATA is not available to create the composer home dir --- src/Composer/Factory.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 9234f46f8..8ea15cde8 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -43,8 +43,14 @@ class Factory $cacheDir = getenv('COMPOSER_CACHE_DIR'); if (!$home) { 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'; } 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'; } }