{"record":{"id":"ff1fa5cc48cf7381","repo":"pypa/pip","slug":"options-outdated-and-uptodate-cannot-be-combin","errorCode":null,"errorMessage":"Options --outdated and --uptodate cannot be combined.","messagePattern":"Options --outdated and --uptodate cannot be combined\\.","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/list.py","lineNumber":177,"sourceCode":"        # Pass allow_yanked=False to ignore yanked versions.\n        selection_prefs = SelectionPreferences(\n            allow_yanked=False,\n            release_control=options.release_control,\n            format_control=options.format_control,\n            prefer_binary=options.prefer_binary,\n        )\n\n        return PackageFinder.create(\n            link_collector=link_collector,\n            selection_prefs=selection_prefs,\n            uploaded_prior_to=options.uploaded_prior_to,\n        )\n\n    def run(self, options: Values, args: list[str]) -> int:\n        cmdoptions.check_release_control_exclusive(options)\n\n        if options.outdated and options.uptodate:\n            raise CommandError(\"Options --outdated and --uptodate cannot be combined.\")\n\n        if options.outdated and options.list_format == \"freeze\":\n            raise CommandError(\n                \"List format 'freeze' cannot be used with the --outdated option.\"\n            )\n\n        cmdoptions.check_list_path_option(options)\n\n        packages: _ProcessedDists = [\n            cast(\"_DistWithLatestInfo\", d)\n            for d in get_environment(options.path).iter_installed_distributions(\n                local_only=options.local,\n                user_only=options.user,\n                editables_only=options.editable,\n                include_editables=options.include_editable,\n                skip=set(stdlib_pkgs),\n            )\n        ]","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/list.py#L159-L195","documentation":"Raised by pip list's run() when both --outdated and --uptodate are passed simultaneously. These flags are logically contradictory: --outdated lists packages with a newer version available, while --uptodate lists packages already at the newest version. Since no package can be in both states, pip rejects the combination rather than returning an empty list.","triggerScenarios":"Invoking `pip list --outdated --uptodate`, or setting both options via a config file / environment variables (PIP_OUTDATED and PIPELINE aliases), or via a shell alias that appends both flags.","commonSituations":"Copy-pasting a pip list command from documentation without removing the irrelevant flag; scripts that build flags dynamically and accidentally concatenate both; stale shell aliases.","solutions":["Use only one of the two flags depending on your goal: `pip list --outdated` to see upgradable packages, or `pip list --uptodate` to see current ones.","If building the command dynamically, ensure the two flags are mutually exclusive in your flag-assembly logic.","Check pip.conf and PIP_* environment variables for both options being set."],"exampleFix":"# before\npip list --outdated --uptodate\n# after\npip list --outdated","handlingStrategy":"validation","validationCode":"def build_pip_list_cmd(outdated: bool, uptodate: bool) -> list[str]:\n    if outdated and uptodate:\n        raise ValueError('--outdated and --uptodate are mutually exclusive')\n    cmd = ['pip', 'list']\n    if outdated:\n        cmd.append('--outdated')\n    if uptodate:\n        cmd.append('--uptodate')\n    return cmd\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --outdated and --uptodate as a mutually exclusive enum in wrapper scripts.","Audit PIP_* env vars and pip.conf for both options."],"tags":["pip","list","cli","options","mutually-exclusive"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}