{"record":{"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":"exception","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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/locations/_sysconfig.py#L134-L170","documentation":"Raised as InvalidSchemeCombination('--home','--prefix') (exceptions.py:283) from get_scheme in _sysconfig.py:151-152. The --home (home scheme) and --prefix (prefix scheme) installation layouts are mutually exclusive and both set overlapping base directories, so get_scheme rejects the combination immediately.","triggerScenarios":"Invoking get_scheme(dist_name, home=<non-None>, prefix=<non-None>) — i.e. `pip install --home /myhome --prefix /myprefix`.","commonSituations":"Combining legacy --home semantics with a modern --prefix; wrapper tooling forwarding distutils-style flags alongside pip --prefix; user misunderstanding that --home and --prefix both redefine the install base.","solutions":["Use either --home or --prefix, not both; pick the scheme that matches your target layout.","For most modern use cases, drop --home and use --prefix (or a virtualenv).","Review the originating command/config file for the stale flag and remove it."],"exampleFix":"// before\npip install --home /opt/home --prefix /opt/prefix mypkg\n// after\npip install --prefix /opt/prefix mypkg","handlingStrategy":"validation","validationCode":"// Reject conflicting flags before calling get_scheme / pip:\nif home and prefix:\n    raise SystemExit('--home and --prefix are mutually exclusive')","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import InvalidSchemeCombination\ntry:\n    scheme = get_scheme(dist, home=home, prefix=prefix)\nexcept InvalidSchemeCombination:\n    # drop one of the conflicting flags\n    ...","preventionTips":["Never combine --home with --prefix.","Modernize legacy --home usage to --prefix or venvs.","Add a guard in build wrappers that flags simultaneous home+prefix."],"tags":["installation","scheme","argument-conflict","sysconfig"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}