Composer finds the package, yet no version of it fits your requirement
Your error
- Root composer.json requires vendor/package ^3.0, found vendor/package[1.0.0, 2.0.0, 2.1.0] but it does not match the constraint.2 more lines it can showFix it fast
Most common cause, 1 of 3The constraint asks for a version that was never released
Require a range that includes a release the list shows.
composer require "vendor/package:^2.1"Short answer
Composer says found vendor/package[versions] but it does not match the constraint when the package exists but no version, not even a pre-release, fits the requirement. Usually that version was never tagged, dev-master is now dev-main, or a dependency requires your own root package. Compare the bracketed list with your constraint. Composer 2.x wording; Composer 1 said rejected by your constraint.
Which cause do you have?
Put the versions Composer can see next to the constraint you wrote. The bracketed list in the error shows the same thing, and the tail of the message (a dev-master hint or a dep-on-root link) points straight at cause 2 or 3.
composer show --all vendor/package
grep -n "vendor/package" composer.jsonThen find the line you see in this list and open its fix:
- 1The constraint asks for a version that was never released
The highest version in the brackets is below the constraint, for example ^3.0 against a list ending at 2.1.0 - 2dev-master is required, but the default branch is now main
The brackets list dev-main (or dev-default) and the message ends with Perhaps dev-master was renamed to dev-main? - 3A dependency requires the root package you are working on
The package in the message is your own project, the list shows only a branch such as dev-main, and the line ends with See https://getcomposer.org/dep-on-root for details and assistance.
What does the error look like?
- Root composer.json requires vendor/package ^3.0, found vendor/package[1.0.0, 2.0.0, 2.1.0] but it does not match the constraint.- Root composer.json requires vendor/package dev-master, found vendor/package[dev-main] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?The requested package vendor/package ^3.0 exists as vendor/package[1.0.0, 2.0.0] but these are rejected by your constraint.
Cause 1 of 3
The constraint asks for a version that was never released
You seeThe highest version in the brackets is below the constraint, for example ^3.0 against a list ending at 2.1.0
Check
In Composer 2 this sentence comes from the last fallback check: the package was found once both minimum-stability and the version requirement were ignored, so the requirement alone excludes every release. Had a beta or RC matched, the message would end with does not match your minimum-stability instead. A typo in the version, a major copied from documentation for an unreleased branch, or a fork that never pushed its tags all end here. Composer 1 described the same case as exists as ... but these are rejected by your constraint.
composer show --all vendor/package | grep -i versionsFix
Require a range that includes a release the list shows. If you need a feature from the next major, wait for its tag or ask the maintainer to publish one.
composer require "vendor/package:^2.1"Verify
composer.json holds the new constraint and the package is installed.
composer show vendor/package | grep -E "^(name|versions)"Confirmed by raw.githubusercontent.com
Cause 2 of 3
dev-master is required, but the default branch is now main
You seeThe brackets list dev-main (or dev-default) and the message ends with Perhaps dev-master was renamed to dev-main?
Check
Composer names a branch version dev- plus the branch name. When a repository renames master to main, the version dev-master disappears and dev-main takes its place. Composer adds the rename hint only when the constraint is exactly dev-master and a dev-main or dev-default version is in the list.
composer show --all vendor/package | grep -E "dev-(main|master|default)"Fix
Require the branch under its current name, or better, a tagged release if the project has one.
composer require "vendor/package:dev-main"Verify
The update resolves and composer.json now shows dev-main.
grep -n "vendor/package" composer.jsonConfirmed by raw.githubusercontent.com
Cause 3 of 3
A dependency requires the root package you are working on
You seeThe package in the message is your own project, the list shows only a branch such as dev-main, and the line ends with See https://getcomposer.org/dep-on-root for details and assistance.
Check
When a plugin or test dependency requires the package whose repository you are in, Composer can only offer the root package's own version. On a branch with no branch alias that version is dev-main, which does not satisfy a range like ^2.0. CI systems that use shallow clones can also stop Composer from detecting the root version at all.
grep -n -A3 "branch-alias" composer.jsonFix
Commit a branch alias on the branch, so dev-main counts as the next version line. In CI, also tell Composer which version the checkout is with COMPOSER_ROOT_VERSION, as the Composer troubleshooting guide shows.
{
"extra": {
"branch-alias": {
"dev-main": "2.0.x-dev"
}
}
}
# CI job
COMPOSER_ROOT_VERSION=dev-main composer installVerify
The install finishes without the dep-on-root problem.
COMPOSER_ROOT_VERSION=dev-main composer installConfirmed by getcomposer.org
How do I stop it coming back?
- Before raising a constraint, run composer show --all for that package and pick a version that the list really contains.
- Point branch requirements at the branch name the repository uses today, and switch to a tagged release as soon as one exists.
- In libraries, keep a branch-alias on the main branch so dependent packages resolve during development.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.