Fix unclear error when a package can be found in lock but not in the remote repo, fixes #9750

main
Jordi Boggiano 3 years ago
parent de8a737015
commit ab84916422
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -268,7 +268,7 @@ class Problem
});
if (!$nonLockedPackages) {
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.');
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.');
}
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
@ -404,6 +404,13 @@ class Problem
}
}
if ($nextRepo instanceof LockArrayRepository) {
$singular = count($higherRepoPackages) === 1;
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',
'found '.self::getPackageList($nextRepoPackages, $isVerbose).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.');
}
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages with higher priority do not match your '.$reason.' and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.');
}

@ -43,7 +43,7 @@ Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
- locked/pkg is locked to version dev-master and an update of this package was not requested.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

@ -43,7 +43,7 @@ Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
- locked/pkg is locked to version dev-master and an update of this package was not requested.
--EXPECT--

@ -0,0 +1,52 @@
--TEST--
Update package which is in lock file but not in remote repo at all should show this error correctly
--COMPOSER--
{
"minimum-stability": "dev",
"repositories": [
{"type": "package", "package": [
{"name": "main/dep", "version": "1.0.0", "require": {"locked/dep": "^2.1"}}
]}
],
"require": {
"main/dep": "*"
}
}
--LOCK--
{
"packages": [
{
"name": "main/dep", "version": "1.0.0",
"require": {"locked/dep": "^2.1"},
"type": "library"
},
{
"name": "locked/dep", "version": "2.1.0",
"type": "library"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--RUN--
update main/dep --with-all-dependencies
--EXPECT-EXIT-CODE--
2
--EXPECT-OUTPUT--
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.1.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
--EXPECT--

@ -0,0 +1,54 @@
--TEST--
Update package which is in lock file but not remote repo due to min-stability should show this error correctly
--COMPOSER--
{
"minimum-stability": "stable",
"repositories": [
{"type": "package", "package": [
{"name": "main/dep", "version": "1.0.0", "require": {"locked/dep": "^2.1"}},
{"name": "locked/dep", "version": "2.x-dev"},
{"name": "locked/dep", "version": "2.0.5"}
]}
],
"require": {
"main/dep": "*"
}
}
--LOCK--
{
"packages": [
{
"name": "main/dep", "version": "1.0.0",
"require": {"locked/dep": "^2.1"},
"type": "library"
},
{
"name": "locked/dep", "version": "2.1.0",
"type": "library"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--RUN--
update main/dep --with-all-dependencies
--EXPECT-EXIT-CODE--
2
--EXPECT-OUTPUT--
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.1.0] in the lock file and locked/dep[2.x-dev] from package repo (defining 3 packages) but it does not match your minimum-stability and is therefore not installable. Make sure you either fix the minimum-stability or avoid updating this package to keep the one from the lock file.
--EXPECT--

@ -0,0 +1,53 @@
--TEST--
Update package which is in lock file but not in remote repo in the correct version should show this error correctly
--COMPOSER--
{
"minimum-stability": "dev",
"repositories": [
{"type": "package", "package": [
{"name": "main/dep", "version": "1.0.0", "require": {"locked/dep": "^2.1"}},
{"name": "locked/dep", "version": "2.0.5"}
]}
],
"require": {
"main/dep": "*"
}
}
--LOCK--
{
"packages": [
{
"name": "main/dep", "version": "1.0.0",
"require": {"locked/dep": "^2.1"},
"type": "library"
},
{
"name": "locked/dep", "version": "2.1.0",
"type": "library"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--RUN--
update main/dep --with-all-dependencies
--EXPECT-EXIT-CODE--
2
--EXPECT-OUTPUT--
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.1.0] in the lock file and locked/dep[2.0.5] from package repo (defining 2 packages) but it does not match your constraint and is therefore not installable. Make sure you either fix the constraint or avoid updating this package to keep the one from the lock file.
--EXPECT--

@ -0,0 +1,57 @@
--TEST--
Update package which is in lower prio repo but not main repo due to min-stability should show this error correctly
--COMPOSER--
{
"minimum-stability": "stable",
"repositories": [
{"type": "package", "package": [
{"name": "main/dep", "version": "1.0.0", "require": {"lower/dep": "^2.1"}},
{"name": "lower/dep", "version": "2.x-dev"},
{"name": "lower/dep", "version": "2.0.5"}
]},
{"type": "package", "package": [
{"name": "lower/dep", "version": "2.1.0"}
]}
],
"require": {
"main/dep": "*"
}
}
--LOCK--
{
"packages": [
{
"name": "main/dep", "version": "1.0.0",
"require": {"lower/dep": "^2.1"},
"type": "library"
},
{
"name": "lower/dep", "version": "2.1.0",
"type": "library"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--RUN--
update main/dep --with-all-dependencies
--EXPECT-EXIT-CODE--
2
--EXPECT-OUTPUT--
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires lower/dep ^2.1 -> satisfiable by lower/dep[2.1.0] from package repo (defining 1 package) but lower/dep[2.x-dev] from package repo (defining 3 packages) has higher repository priority. The packages with higher priority do not match your minimum-stability and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.
--EXPECT--
Loading…
Cancel
Save