From 48d8cc6465b7c2f60e7d0333cc53d4c8cd5c0df6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 6 May 2015 11:48:45 +0100 Subject: [PATCH] Avoid errors when invoking composer global config and there is no global composer.json yet, refs #4002 --- src/Composer/Command/ConfigCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 0a39df22b..a833a5140 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -141,6 +141,11 @@ EOT ? ($this->config->get('home') . '/config.json') : $input->getOption('file'); + // create global composer.json if this was invoked using `composer global config` + if ($configFile === 'composer.json' && !file_exists($configFile) && realpath(getcwd()) === realpath($this->config->get('home'))) { + file_put_contents($configFile, "{\n}\n"); + } + $this->configFile = new JsonFile($configFile); $this->configSource = new JsonConfigSource($this->configFile);