diff --git a/src/Extensions/ComposerLoaderExtension.php b/src/Extensions/ComposerLoaderExtension.php index 700d4a5..363a71a 100644 --- a/src/Extensions/ComposerLoaderExtension.php +++ b/src/Extensions/ComposerLoaderExtension.php @@ -111,8 +111,12 @@ protected function getInstalledConstraint(BaseRepository $repository, $packageNa public function onAfterBuild() { // Mock COMPOSER_HOME if it's not defined already. Composer requires one of the two to be set. - if (!Environment::getEnv('HOME') && !Environment::getEnv('COMPOSER_HOME')) { - putenv('COMPOSER_HOME=/tmp'); + if (!Environment::getEnv('COMPOSER_HOME')) { + $home = Environment::getEnv('HOME'); + if (!$home || !is_dir($home) || !is_writable($home)) { + // Set our own directory + putenv('COMPOSER_HOME=' . sys_get_temp_dir()); + } } $originalDir = getcwd();