astral-sh/uv · error · anyhow::Error
Failed to read `{}`: {}
Error message
Failed to read `{}`: {} What it means
Thrown in from_source_with_cache (crates/uv-requirements/src/specification.rs:298) when fs_err::tokio::read_to_string on a RequirementsSource::PyprojectToml fails with an io error other than NotFound (that kind gets error 46). The underlying error is appended, so the message distinguishes unreadable from missing files.
Source
Thrown at crates/uv-requirements/src/specification.rs:298
RequirementsTxt::parse_with_cache(path, &*CWD, client_builder, cache).await?;
if requirements_txt == RequirementsTxt::default() {
warn_user!(
"Requirements file `{}` does not contain any dependencies",
path.user_display()
);
}
Self::from_requirements_txt(requirements_txt)
}
RequirementsSource::PyprojectToml(path) => {
let content = match fs_err::tokio::read_to_string(&path).await {
Ok(content) => content,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
return Err(anyhow::anyhow!("File not found: `{}`", path.user_display()));
}
Err(err) => {
return Err(anyhow::anyhow!(
"Failed to read `{}`: {}",
path.user_display(),
err
));
}
};
let pyproject_toml = PyProjectToml::from_toml(&content, path.user_display())
.with_context(|| format!("Failed to parse: `{}`", path.user_display()))?;
Self {
source_trees: vec![SourceTree::PyProjectToml(path.clone(), pyproject_toml)],
..Self::default()
}
}
RequirementsSource::Pep723Script(path) => {
let content = if let Some(content) = cache.get(path.as_path()) {
content.clone()
} else {View on GitHub (pinned to f1a42680ff)
Solutions
- Check the appended io error — for permissions, fix them (`chmod +r pyproject.toml` / `chown`)
- If running in a container or CI, ensure the user running uv can read the file (inspect with `ls -l`)
- Retry once if the file was transiently locked or being rewritten during the run
Example fix
# before $ uv pip install -r pyproject.toml Failed to read `pyproject.toml`: Permission denied (os error 13) # after $ chmod +r pyproject.toml $ uv pip install -r pyproject.toml
Defensive patterns
Strategy: try-catch
Validate before calling
match fs_err::tokio::read_to_string(&path).await {
Ok(_) => { /* proceed with RequirementsSource::PyprojectToml(path) */ }
Err(err) if err.kind() == std::io::ErrorKind::NotFound => { /* missing: handle separately */ }
Err(err) => { /* surface permissions/io issue before calling uv */ }
} Try / catch
match RequirementsSpecification::from_source(src, &client_builder).await {
Err(err) if err.to_string().starts_with("Failed to read `") => {
// inspect the trailing io error; fix perms or retry once after transient locks
}
spec => spec?,
} Prevention
- Ensure the invoking user owns or can read project files (especially in containers)
- Avoid rewriting pyproject.toml concurrently while uv runs
- Copy files with preserved permissions in Docker builds
When it happens
Trigger: Reading a pyproject.toml with no read permission (chmod 000, different owner), a directory passed where the file was expected, a file replaced/deleted between the existence check and the read (TOCTOU), or an OS-level io failure (disk, I/O) during `uv pip install -r pyproject.toml`.
Common situations: CI containers running as a non-root user against root-owned checkouts; Docker COPY losing permissions; editors or sync tools holding exclusive locks on Windows; flaky mounts.
Related errors
- The file `{}` appears to be a `{}` file, but overrides must
- The file `{}` appears to be a `pylock.toml` file, but constr
- The file `{}` appears to be a TOML file, but constraints mus
- The file `{}` appears to be a `pylock.toml` file, but overri
- The file `{}` appears to be a TOML file, but overrides must
AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16).
Data as JSON: /api/errors/fcef763238218193.
Report an issue: GitHub.