{"record":{"id":"a848005945e6fb18","repo":"pydantic/monty","slug":"failed-to-read-e","errorCode":null,"errorMessage":"failed to read {}: {e}","messagePattern":"failed to read (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/monty-python/build.rs","lineNumber":46,"sourceCode":"    pyo3_build_config::use_pyo3_cfgs();\n}\n\n/// Rewrite the metapackage's `version` and its pins on this distribution and\n/// `pydantic-monty-runtime` if any has drifted from the Cargo package version.\n///\n/// All three distributions are built from the same workspace and released\n/// together — `pydantic-monty` exists only to install the other two, and the\n/// worker rejects a client whose version differs — so the pins must be exact.\n/// Unlike monty-js there is no lockfile to refresh afterwards: uv.lock records\n/// no specifier for workspace-editable sources.\n///\n/// Uses the runtime `CARGO_PKG_VERSION` env var (not `env!()`) so that the build\n/// script picks up version changes without needing to be recompiled.\nfn sync_meta_pyproject(path: &Path) {\n    let cargo_version = env::var(\"CARGO_PKG_VERSION\").expect(\"CARGO_PKG_VERSION not set\");\n    let pin_version = cargo_version_to_pep440(&cargo_version);\n\n    let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!(\"failed to read {}: {e}\", path.display()));\n\n    let mut result = String::with_capacity(contents.len());\n    let mut changed = false;\n    // one count per entry of `PINNED_DISTS`, plus the `version = ` line\n    let mut pins = [0usize; PINNED_DISTS.len()];\n    let mut versions = 0usize;\n\n    for line in contents.lines() {\n        let synced = if let Some(index) = pinned_dist(line) {\n            pins[index] += 1;\n            // Preserve the presence/absence of the trailing comma (the last\n            // entry in the dependencies array has none).\n            let comma = if line.ends_with(',') { \",\" } else { \"\" };\n            Cow::Owned(format!(\"    \\\"{}=={pin_version}\\\"{comma}\", PINNED_DISTS[index]))\n        } else if line.starts_with(\"version = \\\"\") {\n            versions += 1;\n            Cow::Owned(format!(\"version = \\\"{pin_version}\\\"\"))\n        } else {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-python/build.rs#L28-L64","documentation":"The pydantic-monty-client build script syncs the pinned dist versions in packages/pydantic-monty/pyproject.toml from the Cargo workspace version. It panics with this message when fs::read_to_string on the pyproject.toml fails — the file is missing, unreadable, or the path is wrong at build time.","triggerScenarios":"Running `cargo build`/`cargo publish` for crates/monty-python when packages/pydantic-monty/pyproject.toml does not exist, was deleted, moved, or is unreadable due to file permissions.","commonSituations":"Fresh checkout missing the metapackage directory; build run from a sparse/partial workspace; a refactor renamed packages/pydantic-monty; build executed in a container that copied only part of the repo.","solutions":["Restore packages/pydantic-monty/pyproject.toml (git checkout -- packages/pydantic-monty/pyproject.toml or a fresh clone)","Verify the file path/permissions: ls -l packages/pydantic-monty/pyproject.toml","If the metapackage moved, update the path constant in crates/monty-python/build.rs"],"exampleFix":"// before\n$ cargo build -p pydantic-monty-client\npanicked: failed to read packages/pydantic-monty/pyproject.toml: No such file or directory\n\n// after\ngit checkout -- packages/pydantic-monty/pyproject.toml\ncargo build -p pydantic-monty-client  # succeeds","handlingStrategy":"validation","validationCode":"test -f packages/pydantic-monty/pyproject.toml || echo 'metapackage pyproject.toml missing'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the full workspace checked out (no partial/sparse copies) before building","Do not delete or move packages/pydantic-monty without updating build.rs","Check out with git clone (not selective file copies) in CI and containers"],"tags":["build-script","cargo","pyproject","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}