From a2a3ad51abe4b9eda4035204eb5ba1e0af13124b Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Fri, 14 Sep 2018 10:34:23 +1200 Subject: [PATCH] FIX Don't blindly assume that HOME is writable --- src/Extensions/ComposerLoaderExtension.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Extensions/ComposerLoaderExtension.php b/src/Extensions/ComposerLoaderExtension.php index 2c1991e..8336f55 100644 --- a/src/Extensions/ComposerLoaderExtension.php +++ b/src/Extensions/ComposerLoaderExtension.php @@ -100,8 +100,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 (!getenv('HOME') && !getenv('COMPOSER_HOME')) { - putenv('COMPOSER_HOME=/tmp'); + if (!getenv('COMPOSER_HOME')) { + $home = getenv('HOME'); + if (!$home || !is_dir($home) || !is_writable($home)) { + // Set our own directory + putenv('COMPOSER_HOME=' . sys_get_temp_dir()); + } } $originalDir = getcwd();