{"id":"4f07628831f64cc5","repo":"pypa/pip","slug":"cannot-set-home-and-prefix-together","errorCode":null,"errorMessage":"Cannot set --home and --prefix together","messagePattern":"Cannot set --home and --prefix together","errorType":"validation","errorClass":"InvalidSchemeCombination","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/locations/_sysconfig.py","lineNumber":152,"sourceCode":"    prefix: str | None = None,\n) -> Scheme:\n    \"\"\"\n    Get the \"scheme\" corresponding to the input parameters.\n\n    :param dist_name: the name of the package to retrieve the scheme for, used\n        in the headers scheme path\n    :param user: indicates to use the \"user\" scheme\n    :param home: indicates to use the \"home\" scheme\n    :param root: root under which other directories are re-based\n    :param isolated: ignored, but kept for distutils compatibility (where\n        this controls whether the user-site pydistutils.cfg is honored)\n    :param prefix: indicates to use the \"prefix\" scheme and provides the\n        base directory for the same\n    \"\"\"\n    if user and prefix:\n        raise InvalidSchemeCombination(\"--user\", \"--prefix\")\n    if home and prefix:\n        raise InvalidSchemeCombination(\"--home\", \"--prefix\")\n\n    if home is not None:\n        scheme_name = _infer_home()\n    elif user:\n        scheme_name = _infer_user()\n    else:\n        scheme_name = _infer_prefix()\n\n    # Special case: When installing into a custom prefix, use posix_prefix\n    # instead of osx_framework_library. See _should_use_osx_framework_prefix()\n    # docstring for details.\n    if prefix is not None and scheme_name == \"osx_framework_library\":\n        scheme_name = \"posix_prefix\"\n\n    if home is not None:\n        variables = {k: home for k in _HOME_KEYS}\n    elif prefix is not None:\n        variables = {k: prefix for k in _HOME_KEYS}","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/locations/_sysconfig.py#L134-L170","documentation":"InvalidSchemeCombination raised by get_scheme() when both home=<set> and prefix=<set> are passed. Like --user/--prefix, --home and --prefix are distinct, mutually exclusive installation schemes and cannot be combined; the check at line 151-152 rejects the combination immediately.","triggerScenarios":"Calling get_scheme(dist_name, home='/h', prefix='/p') or running pip with both --home and --prefix. These are legacy distutils-style options that map to separate sysconfig schemes.","commonSituations":"Carrying over old distutils invocations that set --home and --prefix together; a wrapper/build script that always passes both; conflicting values inherited from pip.conf.","solutions":["Use only one of --home or --prefix.","Audit pip.conf, PIP_PREFIX / PIP_HOME env vars, and wrapper scripts for the stray option.","Prefer --prefix (the modern, well-supported option) over --home.","Run 'pip config list' to confirm no lingering combined setting."],"exampleFix":"# before\npip install --home /opt/home --prefix /opt/py somepkg\n\n# after\npip install --prefix /opt/py somepkg","handlingStrategy":"validation","validationCode":"def scheme_args_ok(home, prefix) -> bool:\n    return not (home and prefix)\nassert scheme_args_ok(args.home, args.prefix)","typeGuard":"def valid_scheme_combo(home, prefix) -> bool:\n    return not (home and prefix)","tryCatchPattern":"from pip._internal.exceptions import InvalidSchemeCombination\ntry:\n    get_scheme(name, home=h, prefix=p)\nexcept InvalidSchemeCombination as e:\n    # choose --prefix or --home\n    ...","preventionTips":["Do not combine --home and --prefix.","Prefer --prefix over the legacy --home.","Check pip config / env vars for stale options.","Validate install options in wrapper scripts."],"tags":["install-location","scheme","cli","mutually-exclusive"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}