{"record":{"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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/cli/cmdoptions.py#L1271-L1307","documentation":"Raised as CommandError by check_list_path_option (cmdoptions.py:1289) when `pip list` is given both --path and either --user or --local. The --path option restricts listing to a specific installation directory (lines 1276-1284), which is conceptually orthogonal to the --user (user site-packages) and --local (current environment only) scopes, so combining them is ambiguous and rejected at line 1288.","triggerScenarios":"`pip list --path /opt/venv/lib/python3.11/site-packages --user` or `pip list --path <dir> --local`.","commonSituations":"Debugging where a package is installed and stacking scope flags hoping to narrow results; converting a --user/--local workflow to inspect a custom path without removing the old flag.","solutions":["Drop --user/--local and rely solely on --path <dir> to scope the listing to that directory.","Or drop --path and use --user / --local alone."],"exampleFix":"# before\npip list --path /opt/venv/lib/site-packages --user\n# after\npip list --path /opt/venv/lib/site-packages","handlingStrategy":"validation","validationCode":"# Enforce mutual exclusivity of pip list scope flags.\ndef validate_list_scope(opts):\n    if opts.get(\"path\") and (opts.get(\"user\") or opts.get(\"local\")):\n        raise ValueError(\"--path cannot be combined with --user or --local\")\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose exactly one scope for `pip list`: --path, --user, --local, or none."],"tags":["cli-options","list","path","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"}