{"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/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/utils/urls.py#L21-L57","documentation":"ValueError from url_to_path when a `file:` URL contains a non-empty, non-'localhost' netloc (authority) and pip is not running on Windows. On non-Windows, only local file URLs (file:///abs/path or file://localhost/...) are convertible to a path; a remote host in the authority is rejected. On Windows, the same form is interpreted as a UNC share.","triggerScenarios":"Passing a URL like `file://server/share/pkg.tar.gz` (with a host) to pip on Linux/macOS. urlsplit yields a netloc of 'server' which is neither empty nor 'localhost', and since WINDOWS is False, ValueError is raised.","commonSituations":"Trying to install from a UNC/SMB path using file://server/... on Linux; copy-pasting a Windows file URL onto a Linux CI runner; misconfigured index URL.","solutions":["On Linux/macOS, use a fully-local file URL: `file:///abs/path/pkg.tar.gz`.","If you need a network share, mount it locally first, then reference the mount point.","On Windows, the UNC form works; otherwise switch to http(s):// served by a simple index.","Verify with: `python -c \"from urllib.parse import urlsplit; print(urlsplit('file://host/x'))\"`."],"exampleFix":"// before\npip install 'file://nas/share/pkg.tar.gz'   # on Linux\n\n// after\n# mount the share, then use a local path:\npip install '/mnt/nas/share/pkg.tar.gz'\n# or a fully-local URL:\npip install 'file:///mnt/nas/share/pkg.tar.gz'","handlingStrategy":"validation","validationCode":"import sys\nfrom urllib.parse import urlsplit\n\ndef is_local_file_url(url: str) -> bool:\n    if not url.startswith('file:'):\n        return False\n    netloc = urlsplit(url).netloc\n    if sys.platform.startswith('win'):\n        return True  # UNC path form supported\n    return netloc in ('', 'localhost')","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Prefer `file:///abs/path` (three slashes, no host) on Linux/macOS.","Mount network shares locally rather than using file://host/.","Validate URLs in your install scripts before passing them to pip.","On Windows, keep UNC shares or switch to an http index."],"tags":["pip","url","file-uri","platform","configuration"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}