{"record":{"id":"fcef763238218193","repo":"astral-sh/uv","slug":"failed-to-read","errorCode":null,"errorMessage":"Failed to read `{}`: {}","messagePattern":"Failed to read `(.+?)`: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/specification.rs","lineNumber":298,"sourceCode":"                    RequirementsTxt::parse_with_cache(path, &*CWD, client_builder, cache).await?;\n\n                if requirements_txt == RequirementsTxt::default() {\n                    warn_user!(\n                        \"Requirements file `{}` does not contain any dependencies\",\n                        path.user_display()\n                    );\n                }\n\n                Self::from_requirements_txt(requirements_txt)\n            }\n            RequirementsSource::PyprojectToml(path) => {\n                let content = match fs_err::tokio::read_to_string(&path).await {\n                    Ok(content) => content,\n                    Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n                        return Err(anyhow::anyhow!(\"File not found: `{}`\", path.user_display()));\n                    }\n                    Err(err) => {\n                        return Err(anyhow::anyhow!(\n                            \"Failed to read `{}`: {}\",\n                            path.user_display(),\n                            err\n                        ));\n                    }\n                };\n                let pyproject_toml = PyProjectToml::from_toml(&content, path.user_display())\n                    .with_context(|| format!(\"Failed to parse: `{}`\", path.user_display()))?;\n\n                Self {\n                    source_trees: vec![SourceTree::PyProjectToml(path.clone(), pyproject_toml)],\n                    ..Self::default()\n                }\n            }\n            RequirementsSource::Pep723Script(path) => {\n                let content = if let Some(content) = cache.get(path.as_path()) {\n                    content.clone()\n                } else {","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/specification.rs#L280-L316","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","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"],"exampleFix":"# before\n$ uv pip install -r pyproject.toml\nFailed to read `pyproject.toml`: Permission denied (os error 13)\n# after\n$ chmod +r pyproject.toml\n$ uv pip install -r pyproject.toml","handlingStrategy":"try-catch","validationCode":"match fs_err::tokio::read_to_string(&path).await {\n    Ok(_) => { /* proceed with RequirementsSource::PyprojectToml(path) */ }\n    Err(err) if err.kind() == std::io::ErrorKind::NotFound => { /* missing: handle separately */ }\n    Err(err) => { /* surface permissions/io issue before calling uv */ }\n}","typeGuard":null,"tryCatchPattern":"match RequirementsSpecification::from_source(src, &client_builder).await {\n    Err(err) if err.to_string().starts_with(\"Failed to read `\") => {\n        // inspect the trailing io error; fix perms or retry once after transient locks\n    }\n    spec => spec?,\n}","preventionTips":["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"],"tags":["uv","pyproject-toml","io","permissions","pip-interface"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}