8000 Validate command doesn't detect missing packages anymore, neither does 'update nothing'/'update --lock' · Issue #9842 · composer/composer · GitHub < 8000 link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png">
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Validate command doesn't detect missing packages anymore, neither does 'update nothing'/'update --lock' #9842
Closed
@PrinsFrank

Description

@PrinsFrank

Since Composer 2.0.0 (still present in 2.0.12), packages that are present in the composer.json but are not locked in the composer.lock or installed in the vendor folder are not correctly detected as an out of sync lock file, or resolved when running composer update nothing or composer update --lock. In composer 1.10.21 and before, this behaviour was correct.

Reproduction

  1. Create a new folder with this composer.json:
{
    "name": "reproduction/reproduction",
    "description": "reproduction",
    "license": "MIT",
    "require": {
        "php": "^7.4"
    }
}
  1. Run composer update to generate an up to date lock file.
  2. Add an extra dependency manually in the composer.json file (For example a dependency to "composer/semver": "^3.0")

This is not the correct way to add a dependency, but the composer.json and composer.lock might get out of sync in invalid merges, or editors like phpstorm suggest edits to the composer.json without updating the lock file etc.

  1. Run composer validate. An error about an out of date lock file is displayed:
    The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.
  2. Run composer u nothing or composer u --lock
  3. Run composer validate. The warning is now gone implicating the lock file is up to date. The lock file is not up to date however as dependencies from the composer.json are not in the lock file or installed into the vendor folder.

Expected behaviour

  1. When a package is present in the composer.json file but not locked in the composer.lock file a warning is displayed when running composer validate.
  2. When composer update nothing or composer update --lock is ran, the package is installed and added to the lock file (How this previously worked in v1.*) or a warning is displayed to not manually add to the composer.json file with a message to run composer require vendor/package-name to require the package correctly and fix the discrepancy between the two files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0