zylon-ai/private-gpt · warning
Unknown command: {cmd!r}
Error message
Unknown command: {cmd!r} What it means
CLI error from private_gpt/cli/main.py's pre-dispatch guard. If sys.argv[1] is a non-flag token not in _KNOWN_COMMANDS (serve, run, help), the CLI prints 'Unknown command: <cmd>' — with a 'Did you mean' suggestion via difflib when a close match exists — and exits 1 before Typer's app() runs. This exists to give fast, Typer-independent typo feedback.
Source
Thrown at private_gpt/cli/main.py:67
_KNOWN_COMMANDS = ["serve", "run", "help"]
if _CELERY_AVAILABLE:
_KNOWN_COMMANDS.append("worker")
def main() -> None:
if len(sys.argv) > 1:
cmd = sys.argv[1]
if not cmd.startswith("-") and cmd not in _KNOWN_COMMANDS:
matches = difflib.get_close_matches(cmd, _KNOWN_COMMANDS, n=1, cutoff=0.6)
if matches:
typer.echo(
f"Unknown command: {cmd!r}. Did you mean: {matches[0]!r}?",
err=True,
)
else:
typer.echo(f"Unknown command: {cmd!r}", err=True)
raise SystemExit(1)
app()
if __name__ == "__main__":
main()
View on GitHub (pinned to 4a030776a3)
Solutions
- Use a known command: `private-gpt serve`, `private-gpt run`, or `private-gpt help`.
- Read the suggestion in the error output — difflib usually proposes the intended command.
- Run `private-gpt --help` (a flag, so it bypasses the guard) to list available commands for your version.
- Update scripts after upgrading to a CLI whose command set changed.
Example fix
// before $ private-gpt sevre Unknown command: 'sevre'. Did you mean: 'serve'? // after $ private-gpt serve
Defensive patterns
Strategy: validation
Validate before calling
import subprocess
KNOWN = {"serve", "run", "help"}
cmd = "sevre"
if cmd not in KNOWN:
import difflib
suggestion = difflib.get_close_matches(cmd, KNOWN, n=1)
raise SystemExit(f"Unknown command {cmd!r}{f', did you mean {suggestion[0]!r}?' if suggestion else ''}") Prevention
- Run `private-gpt --help` to enumerate valid commands.
- Pin script subcommands to the installed version's command set.
- Read the difflib suggestion in the error output.
- Avoid copy-pasting commands from docs of other tools.
When it happens
Trigger: Running `private-gpt sevre` (typo, suggests 'serve'), `private-gpt start`, or any subcommand name that is not literally serve/run/help. Flags like --help pass through untouched.
Common situations: Typos and muscle memory from other CLIs (`start`, `init`, `chat`); scripts pinned to an old CLI version whose command set changed; copy-pasting docs for a different tool.
Related errors
- Binary not found in PATH: {binary!r}
- Server is already running with PID {existing_pid}
- Server did not become ready within {_HEALTH_TIMEOUT}s
- Tokenizer mode {tokenizer_mode} not found.
- Unexpected kwargs: {kwargs}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/3dc81953c54814e4.
Report an issue: GitHub.