Skip to content

documented CLI option syntax with values doesn't work for subcommands #10051

@latk

Description

@latk

Description

I've been trying to use the excellent -P/--project option from #9831. It is documented like this:

$ poetry help run
...
Usage:
  run [options] [--] <args>...
...
  -P, --project=PROJECT      Specify another path as the project root. ...

Using the GNU-style long --project=PROJECT syntax or the more classic short -Pvalue syntax fails with an obscure error:

$ poetry -P. run echo hi
Command not found: run

$ poetry --project=. run echo hi
Command not found: run

$ poetry run -P. -- echo hi
Command not found: -P.

$ poetry run --project=. -- echo hi
Command not found: --project=.

Everything works correctly when the value is space-separated:

$ poetry -P . run echo hi
hi

$ poetry --project . run echo hi
hi

$ poetry run -P . -- echo hi
hi

$ poetry run --project . -- echo hi
hi

Suggested resolution:

  • support the common --option=value and -ovalue syntaxes for command line arguments in addition to space-separated arguments
  • alternatively, adjust the docs (both poetry --help and on the website) to avoid showing --option=value style syntax

This is probably an issue in the underlying python-poetry/cleo library, which documents syntax like "--yell=loud" and has a test for this pattern. But maybe there's some bad interaction with subcommands, or Poetry is using Cleo in some unusual way here. Evidence in favor of the subcommand hypothesis is that a bare poetry -P. does run without errors. Anyways, I'm just a Poetry user and have therefore reported the issue here.

Workarounds

Pass option names and values as separate CLI arguments, not as a single string.

Poetry Installation Method

pipx

Operating System

Ubuntu 24.04

Poetry Version

Poetry (version 2.0.1)

Poetry Configuration

N/A

Python Sysconfig

N/A

Example pyproject.toml

N/A

Poetry Runtime Logs

no relevant logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions