From e132a5a84ad8aac14479713dd7d4b36989180f2b Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 10 Dec 2024 16:37:59 +0100 Subject: [PATCH] Adding explicit message to `why-not` if package is already installed Closes #12227 --- src/Composer/Command/BaseDependencyCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index 55b502e03..b17f3d93a 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -126,6 +126,8 @@ abstract class BaseDependencyCommand extends BaseCommand $extraNotice = ' (version provided by config.platform)'; } $this->getIO()->writeError('Package "'.$needle.' '.$textConstraint.'" found in version "'.$matchedPackage->getPrettyVersion().'"'.$extraNotice.'.'); + } elseif ($inverted) { + $this->getIO()->write('Package "'.$needle.'" '.$matchedPackage->getPrettyVersion().' is already installed! To find out why, run `composer why '.$needle.'`'); } // Include replaced packages for inverted lookups as they are then the actual starting point to consider