{"id":"583cbfe1d754e759","repo":"pypa/pip","slug":"cannot-combine-path-with-user-or-local","errorCode":null,"errorMessage":"Cannot combine '--path' with '--user' or '--local'","messagePattern":"Cannot combine '--path' with '--user' or '--local'","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/cli/cmdoptions.py","lineNumber":1289,"sourceCode":"    help=\"Do not automatically enable --require-hashes \"\n    \"when encountering a requirement with hashes.\",\n)\n\n\nlist_path: Callable[..., Option] = partial(\n    PipOption,\n    \"--path\",\n    dest=\"path\",\n    type=\"path\",\n    action=\"append\",\n    help=\"Restrict to the specified installation path for listing \"\n    \"packages (can be used multiple times).\",\n)\n\n\ndef check_list_path_option(options: Values) -> None:\n    if options.path and (options.user or options.local):\n        raise CommandError(\"Cannot combine '--path' with '--user' or '--local'\")\n\n\nlist_exclude: Callable[..., Option] = partial(\n    PipOption,\n    \"--exclude\",\n    dest=\"excludes\",\n    action=\"append\",\n    metavar=\"package\",\n    type=\"package_name\",\n    help=\"Exclude specified package from the output\",\n)\n\n\nno_python_version_warning: Callable[..., Option] = partial(\n    Option,\n    \"--no-python-version-warning\",\n    dest=\"no_python_version_warning\",\n    action=\"store_true\",","sourceCodeStart":1271,"sourceCodeEnd":1307,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/cli/cmdoptions.py#L1271-L1307","documentation":"Raised by check_list_path_option() in cmdoptions.py:1289 when `pip list` is called with --path together with either --user or --local. These are mutually exclusive scope filters: --path restricts to a specific directory, while --user and --local restrict to the user site and current environment respectively. Combining them is ambiguous.","triggerScenarios":"Calling `pip list --path ./libs --user` or `pip list --path ./libs --local` or `pip list --path ./libs --user --local`.","commonSituations":"Scripts that combine pip list flags indiscriminately. Debugging package installations across multiple locations and trying to narrow scope in multiple ways at once. Shell aliases that always include --user.","solutions":["Use only --path to list packages in a specific directory: `pip list --path ./libs`.","Use only --user to list user-site packages: `pip list --user`.","Use only --local to list packages in the current environment: `pip list --local`.","Run separate pip list commands for each scope if you need to check multiple locations."],"exampleFix":"# before\npip list --path ./libs --user\n\n# after\npip list --path ./libs\n# or separately:\npip list --user","handlingStrategy":"validation","validationCode":"def validate_list_path_options(options):\n    \"\"\"Ensure --path is not combined with --user or --local.\"\"\"\n    if options.get('path') and (options.get('user') or options.get('local')):\n        return False\n    return True","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import CommandError\ntry:\n    # pip list --path ... --user\nexcept CommandError as e:\n    if \"'--path'\" in str(e):\n        # remove --user or --local and retry\n","preventionTips":["Use only one scope-filtering option with pip list.","Run separate pip list commands for different scopes.","Avoid blanket aliases that always include --user."],"tags":["cli","pip-list","option-conflict","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}