composer: Exception: No lockfile found. Unable to read locked packages

When I dont have any requirements, I get an exception thrown at my saying:

No lockfile found. Unable to read locked packages

My composer.json:

{
    "name": "tobias/composer-issue",
    "require": {},
    "autoload": {
        "psr-4": { "App\\": "src/" }
    }
}

Output of composer diagnose:

composer diagnose
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.9.0
PHP version: 7.3.6
PHP binary path: /usr/local/Cellar/php/7.3.6/bin/php

When I run this command:

composer dump-autoload

I get the following output:

Generating autoload files
                                                     
  [LogicException]                                   
  No lockfile found. Unable to read locked packages  
                                                     

dump-autoload [--no-scripts] [-o|--optimize] [-a|--classmap-authoritative] [--apcu] [--no-dev]

And I expected this to happen:

I expected no exception. I did get autoload files though.

The same happens if I run composer update.

Priority

I can understand that has low priority.

Workaround

My workaround to this was composer require nyholm/noop.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 17 (7 by maintainers)

Most upvoted comments

instead of the workaroudn composer require nyholm/noop, I used composer require php ~7.3.