@ -21,6 +21,8 @@ use Composer\Package\PackageInterface;
*/
*/
class SolverProblemsException extends \RuntimeException
class SolverProblemsException extends \RuntimeException
{
{
const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
/** @var Problem[] */
/** @var Problem[] */
protected $problems;
protected $problems;
/** @var array<Rule[]> */
/** @var array<Rule[]> */
@ -35,7 +37,7 @@ class SolverProblemsException extends \RuntimeException
$this->problems = $problems;
$this->problems = $problems;
$this->learnedPool = $learnedPool;
$this->learnedPool = $learnedPool;
parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
}
}
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
// used/declared in SolverProblemsException, carried over here for completeness
const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
/**
/**
* @var IOInterface
* @var IOInterface
*/
*/
@ -209,6 +216,7 @@ class Installer
*
*
* @throws \Exception
* @throws \Exception
* @return int 0 on success or a positive error code on failure
* @return int 0 on success or a positive error code on failure
* @phpstan-return self::ERROR_*
*/
*/
public function run()
public function run()
{
{
@ -387,7 +395,7 @@ class Installer
if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
$this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
$this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
if (0 !== count($lockTransaction->getOperations())) {
if (0 !== count($lockTransaction->getOperations())) {
$this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
$this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
return 1;
return self::ERROR_LOCK_FILE_INVALID;
}
}
} catch (SolverProblemsException $e) {
} catch (SolverProblemsException $e) {
$err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
$err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';