From a61a8d78b13e2bb2eee7178552ab55168406b213 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 31 Jan 2018 16:11:37 +0100 Subject: [PATCH] Fix warning for packages not existing while they exist but not at the required stability, fixes #7044 --- src/Composer/Command/InitCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 33df93a8b..a17efe6b9 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -705,8 +705,18 @@ EOT )); } + // Check for similar names/typos $similar = $this->findSimilar($name); if ($similar) { + // Check whether the minimum stability was the problem but the package exists + if ($requiredVersion === null && in_array($name, $similar, true)) { + throw new \InvalidArgumentException(sprintf( + 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.', + $name, + $this->getMinimumStability($input) + )); + } + throw new \InvalidArgumentException(sprintf( "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s", $name,