Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Composer says a package could not be found in any version

ErrorThe requested package ... could not be found in any version

Short answer

Composer can only install what its repositories list at a stability it allows. The error comes from a mistyped name, a minimum-stability that hides the only version, or a Git package that was never declared in the root composer.json. A branch also needs the dev- prefix.

  • Applies to Composer 2, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the failing command with verbose output. It shows which repositories Composer asked and what it found.

    composer update -v
  2. 2Match what you see, then jump to its fix

    1. 1The package is not found even though you expect it on PackagistThe package name or version has a typoFix
    2. 2The package has only dev, alpha or beta releasesminimum-stability hides the only versionFix
    3. 3The package is a private or forked repository that is not on PackagistA Git package is not declared in the root composer.jsonFix
    4. 4You just tagged a version and Composer cannot see itThe release is brand newFix

What does the error look like?

  • The requested package ... could not be found in any version

Cause 1 of 4

The package name or version has a typo

1Check

Check the vendor/name pair and the branch or tag name in composer.json for typos. Run the built-in checks too.

composer diagnose
composer why-not vendor/package 2.0

2Fix

Correct the name and constraint to match the package page.

composer require vendor/package

3Verify

Composer resolves and installs the package.

composer update vendor/package -v

Confirmed by getcomposer.org

Did this fix it?

Cause 2 of 4

minimum-stability hides the only version

1Check

The default minimum-stability is stable, so versions less stable than that are ignored. Set it to dev temporarily to rule this out.

grep -n "minimum-stability" composer.json

2Fix

Allow the one package with an inline flag, or lower the stability in the root composer.json and keep prefer-stable on.

"require": {
    "vendor/package": "^1.0@beta"
}

3Verify

Run the require again and read the chosen version.

composer require vendor/package:^1.0@beta

Confirmed by getcomposer.org

Did this fix it?

Cause 3 of 4

A Git package is not declared in the root composer.json

1Check

A repositories entry only counts in the root package. One that sits inside a dependency's composer.json is ignored.

grep -n -A4 "repositories" composer.json

2Fix

Declare the repository in the root composer.json, keep the original package name, and use the dev- prefix for a branch.

{
    "repositories": [
        { "type": "vcs", "url": "https://github.com/acme/forked-package" }
    ],
    "require": {
        "acme/forked-package": "dev-bugfix"
    }
}

3Verify

Update the one package.

composer update acme/forked-package -v

Confirmed by getcomposer.org

Did this fix it?

Cause 4 of 4

The release is brand new

1Check

New versions can take up to a minute to appear on Packagist. Clear the local cache before you try again.

composer clear-cache

2Fix

Wait a minute, clear the cache and run the update again.

composer update vendor/package

3Verify

The new version shows up.

composer update vendor/package -v

Confirmed by getcomposer.org

Did this fix it?

How do I stop it coming back?

  • Copy the exact package name from its Packagist page.
  • Keep private repository entries in the root composer.json and commit it.
  • Tag releases in Git so a constraint can match them.

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.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Apache returns 403 when a URL contains %3F

a request like /page%3Fname=test is refused while /page?name=test works

Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.