From 1cfdaf43f1106231285b6d284b707dcbd964743b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 4 Dec 2021 14:56:32 +0100 Subject: [PATCH] Fix new file being leftover if require in new dir fails to resolve requirements --- src/Composer/Command/RequireCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index b2c5239fb..751e99d21 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -206,6 +206,8 @@ EOT ); } catch (\Exception $e) { if ($this->newlyCreated) { + $this->revertComposerFile(false); + throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e); }