1
0
Fork 0

Also hint for errors when the root package does not match the constraint

pull/9925/head
Jordi Boggiano 2021-05-25 23:04:41 +02:00
parent 21c70c2606
commit 0dce0f80f1
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 22 additions and 4 deletions

View File

@ -294,6 +294,13 @@ class Problem
} }
} }
// check if the root package is a name match and hint the dependencies on root troubleshooting article
$allReposPackages = $packages;
$topPackage = reset($allReposPackages);
if ($topPackage instanceof RootPackageInterface) {
$suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
}
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.' . $suffix); return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.' . $suffix);
} }
@ -432,7 +439,6 @@ class Problem
if ($higherRepoPackages) { if ($higherRepoPackages) {
$topPackage = reset($higherRepoPackages); $topPackage = reset($higherRepoPackages);
if ($topPackage instanceof RootPackageInterface) { if ($topPackage instanceof RootPackageInterface) {
$singular = count($nextRepoPackages) === 1;
return array( return array(
"- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ', "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.' 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.'

View File

@ -5,7 +5,8 @@ Circular dependencies errors uses helpful message
"name": "root/pkg", "name": "root/pkg",
"version": "dev-master", "version": "dev-master",
"require": { "require": {
"requires/root": "1.0.0" "requires/root": "1.0.0",
"requires/root2": "1.0.0"
}, },
"repositories": [ "repositories": [
{ {
@ -19,6 +20,14 @@ Circular dependencies errors uses helpful message
"root/pkg": "^1.0" "root/pkg": "^1.0"
} }
}, },
{
"name": "requires/root2",
"version": "1.0.0",
"source": { "reference": "some.branch", "type": "git", "url": "" },
"require": {
"root/pkg": "^2.0"
}
},
{ {
"name": "root/pkg", "name": "root/pkg",
"version": "1.0.0" "version": "1.0.0"
@ -40,6 +49,9 @@ Your requirements could not be resolved to an installable set of packages.
Problem 1 Problem 1
- Root composer.json requires requires/root 1.0.0 -> satisfiable by requires/root[1.0.0]. - Root composer.json requires requires/root 1.0.0 -> satisfiable by requires/root[1.0.0].
- requires/root 1.0.0 requires root/pkg ^1.0 -> satisfiable by root/pkg[1.0.0] from package repo (defining 2 packages) but root/pkg is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance. - requires/root 1.0.0 requires root/pkg ^1.0 -> satisfiable by root/pkg[1.0.0] from package repo (defining 3 packages) but root/pkg is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.
Problem 2
- Root composer.json requires requires/root2 1.0.0 -> satisfiable by requires/root2[1.0.0].
- requires/root2 1.0.0 requires root/pkg ^2.0 -> found root/pkg[dev-master] but it does not match the constraint. See https://getcomposer.org/dep-on-root for details and assistance.
--EXPECT-- --EXPECT--

View File

@ -60,6 +60,6 @@ Your lock file does not contain a compatible set of packages. Please run compose
Problem 1 Problem 1
- b/requirer is locked to version 1.0.0 and an update of this package was not requested. - b/requirer is locked to version 1.0.0 and an update of this package was not requested.
- b/requirer 1.0.0 requires root/pkg ^1 -> found root/pkg[2.x-dev] but it does not match the constraint. - b/requirer 1.0.0 requires root/pkg ^1 -> found root/pkg[2.x-dev] but it does not match the constraint. See https://getcomposer.org/dep-on-root for details and assistance.
--EXPECT-- --EXPECT--