From 03085c8181447dbcc1cd5175e0be7317fad25122 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Mon, 16 Oct 2023 18:29:27 +0200 Subject: [PATCH 1/5] Fix Git Driver to use supported Git VCS driver URL Otherwise the URL may not be supported since 3bb191a46 (Add support for env vars and ~ (for HOME) in repo paths for vcs and artifact repositories, fixes #11409 (#11453), 2023-05-07) --- src/Composer/Repository/VcsRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 02a5f9627..d10ad87a0 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -91,7 +91,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt 'svn' => 'Composer\Repository\Vcs\SvnDriver', ]; - $this->url = Platform::expandPath($repoConfig['url']); + $this->url = $repoConfig['url'] = Platform::expandPath($repoConfig['url']); $this->io = $io; $this->type = $repoConfig['type'] ?? 'vcs'; $this->isVerbose = $io->isVerbose(); From 81b662d3888b7e1a0f81377c3f9aceb77fad3ab8 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 26 Oct 2023 10:08:03 +0100 Subject: [PATCH 2/5] Suggest running 'require' not 'update' if a root req fails to update (#11691) --- src/Composer/Command/BaseDependencyCommand.php | 18 +++++++++++++++++- .../Test/Command/BaseDependencyCommandTest.php | 10 +++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index d3b690eca..e010c122a 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -152,7 +152,23 @@ abstract class BaseDependencyCommand extends BaseCommand } if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) { - $this->getIO()->writeError('Not finding what you were looking for? Try calling `composer update "'.$input->getArgument(self::ARGUMENT_PACKAGE).':'.$input->getArgument(self::ARGUMENT_CONSTRAINT).'" --dry-run` to get another view on the problem.'); + $composerCommand = 'update'; + + foreach ($composer->getPackage()->getRequires() as $rootRequirement) { + if ($rootRequirement->getTarget() === $needle) { + $composerCommand = 'require'; + break; + } + } + + foreach ($composer->getPackage()->getDevRequires() as $rootRequirement) { + if ($rootRequirement->getTarget() === $needle) { + $composerCommand = 'require --dev'; + break; + } + } + + $this->getIO()->writeError('Not finding what you were looking for? Try calling `composer '.$composerCommand.' "'.$needle.':'.$textConstraint.'" --dry-run` to get another view on the problem.'); } return 0; diff --git a/tests/Composer/Test/Command/BaseDependencyCommandTest.php b/tests/Composer/Test/Command/BaseDependencyCommandTest.php index 78b41d223..8b0230dfc 100644 --- a/tests/Composer/Test/Command/BaseDependencyCommandTest.php +++ b/tests/Composer/Test/Command/BaseDependencyCommandTest.php @@ -396,11 +396,11 @@ OUTPUT $secondDevNestedRequiredPackage = self::getPackage('vendor2/package3', '1.4.0'); $this->createComposerLock( - [$someRequiredPackage], + [$someRequiredPackage], [$firstDevRequiredPackage, $secondDevRequiredPackage] ); $this->createInstalledJson( - [$someRequiredPackage], + [$someRequiredPackage], [$firstDevRequiredPackage, $secondDevRequiredPackage, $secondDevNestedRequiredPackage] ); @@ -425,7 +425,7 @@ OUTPUT << 'vendor1/package1', 'version' => '^1.3'], << Date: Thu, 26 Oct 2023 11:24:28 +0200 Subject: [PATCH 3/5] Fix build on 2.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 70f488506..78dae74a8 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "psr/log": "^1.0 || ^2.0 || ^3.0", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.2", - "symfony/console": "^5.4.11 || ^6.0.11 || ^7", + "symfony/console": "^5.4.11 || ^6.0.11", "symfony/filesystem": "^5.4 || ^6.0 || ^7", "symfony/finder": "^5.4 || ^6.0 || ^7", "symfony/process": "^5.4 || ^6.0 || ^7", From 8c0f1e10dc610cd47acc651c56d3319c9fd370cd Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 26 Oct 2023 10:38:02 +0100 Subject: [PATCH 4/5] Display error instead of throwing exception when unable to update with temporary constraint (#11692) --- src/Composer/Command/UpdateCommand.php | 4 +++- tests/Composer/Test/Command/UpdateCommandTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 7b6948004..0f414ac39 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -160,7 +160,9 @@ EOT $parsedConstraint = $parser->parseConstraints($constraint); $temporaryConstraints[$package] = $parsedConstraint; 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('The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')'); + $io->write('Run `composer require '.$package.'` or `composer require '.$package.':'.$constraint.'` instead to replace the constraint'); + return self::FAILURE; } } diff --git a/tests/Composer/Test/Command/UpdateCommandTest.php b/tests/Composer/Test/Command/UpdateCommandTest.php index 18e57d1ee..5564eafae 100644 --- a/tests/Composer/Test/Command/UpdateCommandTest.php +++ b/tests/Composer/Test/Command/UpdateCommandTest.php @@ -89,6 +89,15 @@ Your requirements could not be resolved to an installable set of packages. Problem 1 - 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). +OUTPUT + ]; + + yield 'update with temporary constraint failing resolution on root package' => [ + $rootDepAndTransitiveDep, + ['--with' => ['root/req:^2']], + << Date: Thu, 26 Oct 2023 11:38:51 +0200 Subject: [PATCH 5/5] Update lock hash --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 48a8ba35b..d6c04be60 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4bceaf933dcf6bc05808134e78d21496", + "content-hash": "eee3f28cd8914387a15be876bfe67f35", "packages": [ { "name": "composer/ca-bundle",