{"record":{"id":"d008dfa855b80fd6","repo":"pypa/pip","slug":"pre-cannot-be-used-with-all-releases-or-only","errorCode":null,"errorMessage":"--pre cannot be used with --all-releases or --only-final.","messagePattern":"--pre cannot be used with --all-releases or --only-final\\.","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/cli/cmdoptions.py","lineNumber":795,"sourceCode":"        help=\"Only allow final releases (no pre-releases) for a package. Can be \"\n        \"supplied multiple times, and each time adds to the existing value. \"\n        'Accepts either \":all:\" to disable pre-releases for all packages, '\n        '\":none:\" to empty the set, or one or more package names with commas '\n        \"between them. Cannot be used with --pre.\",\n    )\n\n\ndef check_release_control_exclusive(options: Values) -> None:\n    \"\"\"\n    Raise an error if --pre is used with --all-releases or --only-final,\n    and transform --pre into --all-releases :all: if used alone.\n    \"\"\"\n    if not hasattr(options, \"pre\") or not options.pre:\n        return\n\n    release_control = options.release_control\n    if release_control.all_releases or release_control.only_final:\n        raise CommandError(\"--pre cannot be used with --all-releases or --only-final.\")\n\n    # Transform --pre into --all-releases :all:\n    release_control.all_releases.add(\":all:\")\n\n\nplatforms: Callable[..., Option] = partial(\n    Option,\n    \"--platform\",\n    dest=\"platforms\",\n    metavar=\"platform\",\n    action=\"append\",\n    default=None,\n    help=(\n        \"Only use wheels compatible with <platform>. Defaults to the \"\n        \"platform of the running system. Use this option multiple times to \"\n        \"specify multiple platforms supported by the target interpreter.\"\n    ),\n)","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/cli/cmdoptions.py#L777-L813","documentation":"Raised as CommandError by check_release_control_exclusive (cmdoptions.py:795) when --pre is combined with --all-releases or --only-final. The function (lines 785-798) treats --pre as sugar for --all-releases :all: when used alone; supplying both --pre and one of the newer explicit release-control flags is ambiguous, so pip rejects it. The legacy --pre flag and the new --all-releases/--only-final flags are alternative ways to express release-stage filtering.","triggerScenarios":"`pip install --pre --all-releases <pkg>` or `pip install --pre --only-final <pkg>`.","commonSituations":"Migrating a script that used --pre onto the new release-control options and forgetting to remove the old flag; misunderstanding that --pre already implies accepting pre-releases.","solutions":["Use only --pre if you want pre-releases included (it is converted to --all-releases :all: internally).","Or use only --all-releases/--only-final for explicit control and drop --pre."],"exampleFix":"# before\npip install --pre --only-final <pkg>\n# after\npip install --only-final <pkg>","handlingStrategy":"validation","validationCode":"# Normalize release-control flags to exactly one mechanism.\ndef normalize_release_flags(opts):\n    if opts.get(\"pre\") and (opts.get(\"all_releases\") or opts.get(\"only_final\")):\n        raise ValueError(\"Use --pre OR --all-releases/--only-final, not both\")\n    if opts.get(\"pre\"):\n        opts[\"all_releases\"] = \":all:\"\n        opts.pop(\"pre\", None)\n    return opts","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one release-stage mechanism and document it in your install scripts.","When migrating off --pre, remove it rather than stacking it on the new flags."],"tags":["cli-options","pre-release","release-control","conflict","command-error"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}