Skip to content

Commit

Permalink
Hint composer require alternatives if dep resolution fails, fixes #10136
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Oct 14, 2021
1 parent 260ac00 commit f776f52
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Composer/Command/RequireCommand.php
Expand Up @@ -387,6 +387,14 @@ private function doUpdate(InputInterface $input, OutputInterface $output, IOInte

$status = $install->run();
if ($status !== 0) {
if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
if (!isset($req['version'])) {
$io->writeError('You can also try re-running composer require with an explicit version constraint, e.g. "composer require '.$req['name'].':*" to figure out if any version is installable, or "composer require '.$req['name'].':^2.1" if you know which you need.');
break;
}
}
}
$this->revertComposerFile(false);
}

Expand Down

0 comments on commit f776f52

Please sign in to comment.