{"id":"110a99db380ffc6a","repo":"python-poetry/poetry","slug":"unable-to-access-any-of-paths-csv-candidates","errorCode":null,"errorMessage":"Unable to access any of {paths_csv(candidates)}","messagePattern":"Unable to access any of (.+?)","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"src/poetry/utils/env/site_packages.py","lineNumber":204,"sourceCode":"        **kwargs: Any,\n    ) -> tuple[Path, Any] | list[tuple[Path, Any]]:\n        candidates = self.make_candidates(\n            path, writable_only=writable_only, strict=True\n        )\n\n        results = []\n\n        for candidate in candidates:\n            with contextlib.suppress(OSError):\n                result = candidate, getattr(candidate, method)(*args, **kwargs)\n                if return_first:\n                    return result\n                results.append(result)\n\n        if results:\n            return results\n\n        raise OSError(f\"Unable to access any of {paths_csv(candidates)}\")\n\n    def write_text(self, path: Path, *args: Any, **kwargs: Any) -> Path:\n        paths: tuple[Path, Any] = self._path_method_wrapper(\n            path, \"write_text\", *args, **kwargs\n        )\n        return paths[0]\n\n    def mkdir(self, path: Path, *args: Any, **kwargs: Any) -> Path:\n        paths: tuple[Path, Any] = self._path_method_wrapper(\n            path, \"mkdir\", *args, **kwargs\n        )\n        return paths[0]\n\n    def exists(self, path: Path) -> bool:\n        return any(\n            value[-1]\n            for value in self._path_method_wrapper(path, \"exists\", return_first=False)\n        )","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/env/site_packages.py#L186-L222","documentation":"Raised as OSError in SitePackages._path_method_wrapper when every candidate path produced by make_candidates failed the requested filesystem operation (each suppressed OSError). It means the resolved destination(s) exist but the operation could not be performed on any of them.","triggerScenarios":"Calling any SitePackages path method (write_text, mkdir, unlink, etc. via _path_method_wrapper) where each candidate directory raises OSError on the operation - e.g. permission denied, read-only filesystem, or read-only purelib with no writable fallback. Exact branch: site_packages.py:194-204.","commonSituations":"Writing into a read-only system site-packages with no writable user-site fallback; permission/ownership mismatch on the venv's site dir (created as root, run as user); read-only mount or container layer; out of inodes.","solutions":["Check permissions/ownership of the candidate dirs: 'ls -ld <path>' and chown/chmod as needed.","Prefer writable_only=True when calling make_candidates so only writable sites are attempted.","Recreate the venv as the same user that will run Poetry.","If the system env is read-only, enable a writable user-site or use a virtualenv."],"exampleFix":"// before - purelib read-only, no writable fallback\nsite_packages.write_text(Path(\"foo.py\"), \"x\")  # -> OSError on all\n\n// after - target writable candidates only\nsite_packages.write_text(Path(\"foo.py\"), \"x\")  # after fixing perms\n# or ensure a writable user-site is in candidates","handlingStrategy":"try-catch","validationCode":"from poetry.utils.helpers import is_dir_writable\n\ndef any_writable_site(site_packages) -> bool:\n    return any(is_dir_writable(c, create=True) for c in site_packages.candidates)","typeGuard":"def is_unable_to_access_oserror(e: Exception) -> bool:\n    return isinstance(e, OSError) and \"Unable to access any of\" in str(e)","tryCatchPattern":"try:\n    site_packages.write_text(path, data)\nexcept OSError as e:\n    if \"Unable to access any of\" in str(e):\n        # fix perms or redirect to a writable user-site\n        ensure_writable(site_packages.candidates)\n        site_packages.write_text(path, data)\n    else:\n        raise","preventionTips":["Use writable_only=True so only writable sites are attempted.","Create venvs as the same user that runs Poetry to avoid ownership mismatches.","Check directory permissions/ownership before writing into system site-packages.","Ensure a writable user-site or venv exists for read-only system envs."],"tags":["site-packages","permissions","filesystem","io-error"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}