Python "click.exceptions.UsageError" in CI
Click raises UsageError (and exits 2) when a command is invoked with a missing required option, an invalid value, or an unknown subcommand. The traceback names the specific problem.
What this error means
A Click-based CLI step fails with "Error: No such option: --foo", "Error: Missing option '--name'", or "Error: No such command 'bar'".
python
Error: No such option: --new-flagCommon causes
A missing required option or argument
The CI command omitted an option the command marks as required.
An option or subcommand that does not exist in this version
The installed package version does not define the flag or command being passed.
How to fix it
Match the invocation to the command definition
- Run the command with
--helpto see its real options and subcommands. - Supply required options or add them to the @click.option decorators.
- Pin the package so the CLI surface is stable across runs.
Python
@click.command()
@click.option("--name", required=True)
def run(name):
...How to prevent it
- Pin the CLI package version in CI.
- Keep CI invocations aligned with the command signature.
- Use Click testing.CliRunner to cover the invocation in unit tests.
Related guides
Python "argparse: error: unrecognized arguments" in CIFix "error: unrecognized arguments" from argparse in CI - the CLI was passed a flag the parser does not defin…
Python "subprocess.CalledProcessError: returned non-zero exit status" in CIFix "subprocess.CalledProcessError: Command returned non-zero exit status" in CI - a command run with check=T…
Python "KeyError" loading config in CIFix a "KeyError" raised while loading config in CI - code indexed a dict with a key that is present locally b…