Browse Source

Fix warning for packages not existing while they exist but not at the required stability, fixes #7044

Jordi Boggiano 7 years ago
parent
commit
a61a8d78b1
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/Composer/Command/InitCommand.php

+ 10 - 0
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,