python-poetry/poetry · error · OSError
Unable to access any of {paths_csv(candidates)}
Error message
Unable to access any of {paths_csv(candidates)} What it means
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.
Source
Thrown at src/poetry/utils/env/site_packages.py:204
**kwargs: Any,
) -> tuple[Path, Any] | list[tuple[Path, Any]]:
candidates = self.make_candidates(
path, writable_only=writable_only, strict=True
)
results = []
for candidate in candidates:
with contextlib.suppress(OSError):
result = candidate, getattr(candidate, method)(*args, **kwargs)
if return_first:
return result
results.append(result)
if results:
return results
raise OSError(f"Unable to access any of {paths_csv(candidates)}")
def write_text(self, path: Path, *args: Any, **kwargs: Any) -> Path:
paths: tuple[Path, Any] = self._path_method_wrapper(
path, "write_text", *args, **kwargs
)
return paths[0]
def mkdir(self, path: Path, *args: Any, **kwargs: Any) -> Path:
paths: tuple[Path, Any] = self._path_method_wrapper(
path, "mkdir", *args, **kwargs
)
return paths[0]
def exists(self, path: Path) -> bool:
return any(
value[-1]
for value in self._path_method_wrapper(path, "exists", return_first=False)
)View on GitHub (pinned to 92b74dcfe3)
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.
Example fix
// before - purelib read-only, no writable fallback
site_packages.write_text(Path("foo.py"), "x") # -> OSError on all
// after - target writable candidates only
site_packages.write_text(Path("foo.py"), "x") # after fixing perms
# or ensure a writable user-site is in candidates Defensive patterns
Strategy: try-catch
Validate before calling
from poetry.utils.helpers import is_dir_writable
def any_writable_site(site_packages) -> bool:
return any(is_dir_writable(c, create=True) for c in site_packages.candidates) Type guard
def is_unable_to_access_oserror(e: Exception) -> bool:
return isinstance(e, OSError) and "Unable to access any of" in str(e) Try / catch
try:
site_packages.write_text(path, data)
except OSError as e:
if "Unable to access any of" in str(e):
# fix perms or redirect to a writable user-site
ensure_writable(site_packages.candidates)
site_packages.write_text(path, data)
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {path} is not relative to any discovered {site_type}sites
- Unable to find a suitable destination for "{path}" in {paths
- Destination <fg=yellow>{path}</> exists and is not empty. Di
- Specified path '{path}' is not a valid {'directory' if is_di
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/110a99db380ffc6a.json.
Report an issue: GitHub.