1
0
Fork 0

Merge pull request #12231 from ThomasLandauer/patch-1

Adding explicit message to `why-not` if package is already installed
pull/12284/head
Jordi Boggiano 2025-01-20 14:30:13 +01:00 committed by GitHub
commit 34c16ad169
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -126,6 +126,9 @@ abstract class BaseDependencyCommand extends BaseCommand
$extraNotice = ' (version provided by config.platform)';
}
$this->getIO()->writeError('<info>Package "'.$needle.' '.$textConstraint.'" found in version "'.$matchedPackage->getPrettyVersion().'"'.$extraNotice.'.</info>');
} elseif ($inverted) {
$this->getIO()->write('<comment>Package "'.$needle.'" '.$matchedPackage->getPrettyVersion().' is already installed! To find out why, run `composer why '.$needle.'`</comment>');
return 0;
}
// Include replaced packages for inverted lookups as they are then the actual starting point to consider

View File

@ -464,11 +464,10 @@ OUTPUT
0
];
yield 'there is no installed package depending on the package in versions not matching a specific version' => [
yield 'Package is already installed!' => [
['package' => 'vendor1/package1', 'version' => '^1.3'],
<<<OUTPUT
There is no installed package depending on "vendor1/package1" in versions not matching ^1.3
Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.3" --dry-run` to get another view on the problem.
Package "vendor1/package1" 1.3.0 is already installed! To find out why, run `composer why vendor1/package1`
OUTPUT
,
0