{"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/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/cli/cmdoptions.py#L777-L813","documentation":"Raised by check_release_control_exclusive() in cmdoptions.py:795 when --pre is used together with either --all-releases or --only-final. These options are mutually exclusive release-control mechanisms: --pre is a shorthand for 'include pre-releases for all packages', while --all-releases and --only-final provide more granular per-package control. Using them together is ambiguous.","triggerScenarios":"Calling `pip install --pre --all-releases numpy` or `pip install --pre --only-final numpy` or `pip install --pre --all-releases=:all: numpy`.","commonSituations":"Habitually adding --pre to install commands that also use the newer --all-releases/--only-final flags. Transitioning from --pre to the more granular release control options and forgetting to remove --pre. Automation scripts that layer all release-related flags.","solutions":["Remove --pre and use --all-releases=:all: for the same effect (include all pre-releases globally).","Remove --all-releases or --only-final and keep --pre if you just want all pre-releases.","Use --all-releases=<package> for per-package pre-release inclusion without --pre."],"exampleFix":"# before\npip install --pre --all-releases=:all: numpy\n\n# after\npip install --all-releases=:all: numpy\n# (equivalent to --pre but uses the newer API)","handlingStrategy":"validation","validationCode":"def validate_release_flags(options):\n    \"\"\"Ensure --pre is not combined with --all-releases or --only-final.\"\"\"\n    if not options.get('pre'):\n        return True\n    rc = options.get('release_control', {})\n    return not (rc.get('all_releases') or rc.get('only_final'))","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import CommandError\ntry:\n    # pip install with --pre and --all-releases\nexcept CommandError as e:\n    if '--pre' in str(e):\n        # remove --pre or the conflicting release-control flag\n","preventionTips":["Use only one release-control mechanism per command.","Prefer --all-releases/--only-final for granular control over --pre.","Avoid blindly layering all available flags."],"tags":["cli","option-conflict","pre-release","release-control","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}