From c8de960018b78c07e22aeaee76fb121f5faa3256 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 26 May 2021 14:01:04 +0200 Subject: [PATCH] Throw when repo consistency is in question --- src/Composer/Command/InitCommand.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 6b514ebf8..233ce4402 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -889,6 +889,13 @@ EOT // Check for similar names/typos $similar = $this->findSimilar($name); if ($similar) { + if (in_array($name, $similar, true)) { + throw new \InvalidArgumentException(sprintf( + "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.", + $name + )); + } + throw new \InvalidArgumentException(sprintf( "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s", $name,