Skip to content

"composer validate" aborts with code 1 with "--no-check-lock" and JSON Text parse error on lock-file contents #10715

@ktomk

Description

@ktomk

given

{
    "config": {
        "lock": false
    }
}
composer config lock false

and then creating a zero-byte composer.lock file

< /dev/null >| composer.lock

"composer validate --no-check-lock" aborts with exit code 1 choking on the composer.lock file not being valid JSON Text.

Despite the --no-check-lock:

$ composer --no-ansi validate --no-check-lock


  [Seld\JsonLint\ParsingException]
  "./composer.lock" does not contain valid JSON
  Parse error on line 1:

  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['


validate [--no-check-all] [--no-check-lock] [--no-check-publish] [--no-check-version] [-A|--with-dependencies] [--strict] [--] [<file>]

$ echo $?
1

Expected Behavior

The composer.lock file is not checked as per --no-check-lock which should include dropping any errors in JSON Text processing if the file exists.

Additional Info

Report against

$ composer --version
Composer version 2.2.8 2022-03-15 12:55:20

An object with no properties prevents the abortion:

printf '{}' >| composer.lock

And interestingly further validation checks on the lock file (?):

$ composer config lock true # for brevity
$ composer --no-ansi validate --strict
./composer.json is valid

Most of the validate messages related to the lock file with lock: false and --no-check-lock appear noisy to me, but this is rather cosmetic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions