{"record":{"id":"9382d1b94c9a58df","repo":"pypa/pip","slug":"non-local-file-uris-are-not-supported-on-this-plat","errorCode":null,"errorMessage":"non-local file URIs are not supported on this platform: {url!r}","messagePattern":"non-local file URIs are not supported on this platform: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/utils/urls.py","lineNumber":39,"sourceCode":"    \"\"\"\n    Convert a file: URL to a path.\n    \"\"\"\n    import urllib.request\n\n    assert url.startswith(\n        \"file:\"\n    ), f\"You can only turn file: urls into filenames (not {url!r})\"\n\n    _, netloc, path, _, _ = urllib.parse.urlsplit(url)\n\n    if not netloc or netloc == \"localhost\":\n        # According to RFC 8089, same as empty authority.\n        netloc = \"\"\n    elif WINDOWS:\n        # If we have a UNC path, prepend UNC share notation.\n        netloc = \"\\\\\\\\\" + netloc\n    else:\n        raise ValueError(\n            f\"non-local file URIs are not supported on this platform: {url!r}\"\n        )\n\n    path = urllib.request.url2pathname(netloc + path)\n\n    # On Windows, urlsplit parses the path as something like \"/C:/Users/foo\".\n    # This creates issues for path-related functions like io.open(), so we try\n    # to detect and strip the leading slash.\n    if (\n        WINDOWS\n        and not netloc  # Not UNC.\n        and len(path) >= 3\n        and path[0] == \"/\"  # Leading slash to strip.\n        and path[1] in string.ascii_letters  # Drive letter.\n        and path[2:4] in (\":\", \":/\")  # Colon + end of string, or colon + absolute path.\n    ):\n        path = path[1:]\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/utils/urls.py#L21-L57","documentation":"Raised by url_to_path() when converting a file: URL to a local filesystem path on a non-Windows platform and the URL contains a non-empty, non-localhost network location (host). Only Windows supports UNC-path file URIs (file://host/share); on Linux/macOS any host component other than localhost is rejected.","triggerScenarios":"Calling url_to_path() with a URL like 'file://nas/share/package.whl' where the netloc ('nas') is neither empty nor 'localhost', and the platform is not Windows. The function is used internally when pip resolves a file: URL requirement.","commonSituations":"Referencing a package on a network share via a file://host/path URL on Linux or macOS. Misconfigured index URL using file:// with a hostname. Confusing a UNC path (Windows-only) with a generic file URL.","solutions":["Mount the network share locally and use a plain file:/// or absolute path URL instead","If on Windows, ensure the UNC path syntax is correct (file://server/share)","Use an https index or a local directory path rather than a host-based file URL","For a localhost reference, use 'file://localhost/path' or 'file:///path'"],"exampleFix":"// before (on Linux/macOS)\npip install file://nas.example.com/shared/pkg-1.0.whl\n// after\n# mount the share, then reference the local path\npip install /mnt/nas/shared/pkg-1.0.whl\n# or use file:// with empty/localhost authority\npip install \"file:///mnt/nas/shared/pkg-1.0.whl\"","handlingStrategy":"validation","validationCode":"import urllib.parse, sys\n\ndef file_url_is_local(url: str) -> bool:\n    parsed = urllib.parse.urlsplit(url)\n    if parsed.scheme != 'file':\n        return True  # not a file URL, different concern\n    netloc = parsed.netloc\n    if not netloc or netloc == 'localhost':\n        return True\n    return sys.platform == 'win32'\n\n# before converting a file URL to a path\nif not file_url_is_local(url):\n    raise ValueError(f'non-local file URI not supported on this platform: {url}')","typeGuard":"import urllib.parse, sys\n\ndef is_supported_file_uri(url: str) -> bool:\n    p = urllib.parse.urlsplit(url)\n    return p.scheme != 'file' or not p.netloc or p.netloc == 'localhost' or sys.platform == 'win32'","tryCatchPattern":"from pip._internal.utils.urls import url_to_path\n\ntry:\n    path = url_to_path(url)\nexcept ValueError as e:\n    if 'non-local file URIs' in str(e):\n        # switch to a mounted local path or https index\n        raise ConfigError(f'use a local or https URL instead of: {url}')\n    raise","preventionTips":["Use 'file:///' (empty host) or absolute paths for local files on Linux/macOS","Reserve host-based file:// URLs for Windows UNC shares only","Mount network shares and reference local mount points","Validate file URLs for empty/localhost netloc before passing to pip"],"tags":["url","file-uri","platform","windows","network-share"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}