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']], + <<