diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index ffbd1c7bd68c..80f4109310fa 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -183,6 +183,11 @@ protected function initialize(InputInterface $input, OutputInterface $output): v $io = $this->getIO(); $this->config = Factory::createConfig($io); + // When using --global flag, set baseDir to home directory for correct absolute path resolution + if ($input->getOption('global')) { + $this->config->setBaseDir($this->config->get('home')); + } + $configFile = $this->getComposerConfigFile($input, $this->config); // Create global composer.json if this was invoked using `composer global config`