1
0
Fork 0

Display error instead of throwing exception when unable to update with temporary constraint (#11692)

pull/11699/head
Dan Wallis 2023-10-26 10:38:02 +01:00 committed by GitHub
parent 23be508ea5
commit 8c0f1e10dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -160,7 +160,9 @@ EOT
$parsedConstraint = $parser->parseConstraints($constraint); $parsedConstraint = $parser->parseConstraints($constraint);
$temporaryConstraints[$package] = $parsedConstraint; $temporaryConstraints[$package] = $parsedConstraint;
if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) { if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) {
throw new \InvalidArgumentException('The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')'); $io->writeError('<error>The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')</error>');
$io->write('<info>Run `composer require '.$package.'` or `composer require '.$package.':'.$constraint.'` instead to replace the constraint</info>');
return self::FAILURE;
} }
} }

View File

@ -89,6 +89,15 @@ Your requirements could not be resolved to an installable set of packages.
Problem 1 Problem 1
- Root composer.json requires root/req 1.* -> satisfiable by root/req[1.0.0]. - Root composer.json requires root/req 1.* -> satisfiable by root/req[1.0.0].
- root/req 1.0.0 requires dep/pkg ^1 -> found dep/pkg[1.0.0, 1.0.1, 1.0.2] but it conflicts with your temporary update constraint (dep/pkg:^2). - root/req 1.0.0 requires dep/pkg ^1 -> found dep/pkg[1.0.0, 1.0.1, 1.0.2] but it conflicts with your temporary update constraint (dep/pkg:^2).
OUTPUT
];
yield 'update with temporary constraint failing resolution on root package' => [
$rootDepAndTransitiveDep,
['--with' => ['root/req:^2']],
<<<OUTPUT
The temporary constraint "^2" for "root/req" must be a subset of the constraint in your composer.json (1.*)
Run `composer require root/req` or `composer require root/req:^2` instead to replace the constraint
OUTPUT OUTPUT
]; ];
} }