composer: composer exec fails silently

My composer.json (not relevant):

{
    "name": "user/comp",
    "authors": [
        {
            "name": "user",
            "email": "user@host.com"
        }
    ],
    "require": {}
}

Output of 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

When I run this command:

composer exec notarealcommand

I get the following output:

(nothing)

And I expected this to happen: Get an error message.

When I run this command:

composer -v exec notarealcommand

I get the following output:

> __exec_command: notarealcommand
sh: 1: notarealcommand: not found
Script notarealcommand handling the __exec_command event returned with error code 127

The big problem with this is if I run composer exec codecept run and any of the tests fail then the output is blank.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (13 by maintainers)

Most upvoted comments

Well there should be some middle ground. Composer outputs could be hidden I guess, but hiding the output of the called script or command is a little overkill.

Ok I figured it out. It is because of these lines in the exec command:

        if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        }

This basically means that composer exec always runs as if --quiet is passed, except when you pass in one or multiple verbosity flags (-v|vv|vvv).

In quiet mode, even errors are ignored it seems.

Weird I just ran it through xdebugger. It makes plenty of calls that should write output to stderr, but yet nothing is output. Have to further debug why this is failing.

Ugh.

Ok I don’t know why they would advocate that approach. I recommend you figure out where the codecept binary gets installed (most likely either in bin or in vendor/bin), and then just call that directly, e.g:

bin/codecept build
bin/codecept run

or

vendor/bin/codecept build
vendor/bin/codecept run

composer exec really should not be used imho.