From 93eb19e756aac57d134cb0350e42cbced2befc57 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 17 Jul 2022 10:22:07 +0200 Subject: [PATCH] For custom composer.json paths the default cwd should be that files directory, fixes ergebnis/composer-normalize#865, refs #10935 --- src/Composer/Factory.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 609c1cc24..c8d1fc3d8 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -303,6 +303,11 @@ class Factory */ public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true, $disableScripts = false) { + // if a custom composer.json path is given, we change the default cwd to be that file's directory + if (is_string($localConfig) && is_file($localConfig) && null === $cwd) { + $cwd = dirname($localConfig); + } + $cwd = $cwd ?: (string) getcwd(); // load Composer configuration