Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with separating binary arguments from composer arguments in exec. #5632

Closed
SamMousa opened this issue Aug 29, 2016 · 6 comments
Closed

Issue with separating binary arguments from composer arguments in exec. #5632

SamMousa opened this issue Aug 29, 2016 · 6 comments
Labels
Bug

Comments

@SamMousa
Copy link
Contributor

@SamMousa SamMousa commented Aug 29, 2016

With the following composer.json:

{
    "name": "sam/bug",
    "require": {
        "phpunit/phpunit": "^5.5"
    },
    "authors": [
        {
            "name": "Sam Mousa",
            "email": "sam@mousa.nl"
        }
    ]
}

When I run this command:

composer exec -vvv  -- phpunit -d

I get this output:


  [RuntimeException]                                     
  Invalid working directory specified,  does not exist.  


Exception trace:
 () at phar:///home/sam/bin/composer/src/Composer/Console/Application.php:256
 Composer\Console\Application->getNewWorkingDir() at phar:///home/sam/bin/composer/src/Composer/Console/Application.php:114
 Composer\Console\Application->doRun() at phar:///home/sam/bin/composer/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar:///home/sam/bin/composer/src/Composer/Console/Application.php:102
 Composer\Console\Application->run() at phar:///home/sam/bin/composer/bin/composer:43
 require() at /home/sam/bin/composer:24

And I expected this to happen:

PHPUnit 5.5.4 by Sebastian Bergmann and contributors.

option requires an argument -- d

According to composer exec --help, I should be able to separate binary args from composer args:

Usage:
  exec [options] [--] [<binary>] [<args>]...

Arguments:
  binary                         The binary to run, e.g. phpunit
  args                           Arguments to pass to the binary. Use -- to separate from composer arguments

Options:
  -l, --list                     
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Execute a vendored binary/script

It seems that -- is not properly interpreted. (One workaround is to use quotes: composer exec -vvv -- "phpunit -d").

Either the implementation or the documentation is wrong.

@alcohol alcohol added the Bug label Aug 29, 2016
@Seldaek

This comment has been minimized.

Copy link
Member

@Seldaek Seldaek commented Sep 4, 2016

This is a known issue and fixed in symfony/symfony#11431 but sadly that is only in symfony3 so we will only get it once we bump dependencies to php5.5 :/

@Seldaek Seldaek closed this Sep 4, 2016
@gauthierm

This comment has been minimized.

Copy link

@gauthierm gauthierm commented Oct 4, 2016

Is there an ETA for when this fix will be released? If it's going to be a while before the PHP dep is bumped then the CLI help should be updated to remove the "Use -- to separate from composer arguments" part.

@Seldaek

This comment has been minimized.

Copy link
Member

@Seldaek Seldaek commented Oct 5, 2016

The help text is still relevant, it just doesn't work 100% like with --help and such, but without -- you will get more issues so no we are not removing it.

@gauthierm

This comment has been minimized.

Copy link

@gauthierm gauthierm commented Dec 22, 2016

FWIW this issue prevents me from using composer to run phpunit commands.

@gauthierm

This comment has been minimized.

Copy link

@gauthierm gauthierm commented Feb 10, 2017

This also makes it difficult to run phpcs:

composer exec -- phpcs -h

This returns help for composer and not phpcs. There's no way to use exec to get phpcs help.

@jcrben

This comment has been minimized.

Copy link

@jcrben jcrben commented May 31, 2017

(One workaround is to use quotes: composer exec -vvv -- "phpunit -d").

That workaround doesn't work for me, running composer 1.2.2 and phpunit 4.80 (old, I know...).

What does work is calling the binary directly: ./vendor/bin/phpunit

When I updated to composer 1.4.2 composer exec broke and returned Script phpunit handling the __exec_command event returned with error code 2 for composer exec phpunit.

Is there another issue that we can watch for a fix for this? Perhaps an issue tracking an upgrade to symfony3. I'm also seeing "symfony/console": "^2.5 || ^3.0" for 1.2.2 (https://github.com/composer/composer/blob/1.2.2/composer.json#L31).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.