{"record":{"id":"6a61de8fe75f89ce","repo":"rust-lang/cargo","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_package/mod.rs","lineNumber":621,"sourceCode":"                &pkg,\n                &license_path,\n                \"license-file\",\n                &mut invalid_manifest_field,\n            );\n        }\n    }\n    if let Some(readme) = &pkg.manifest().metadata().readme {\n        let readme_path = Path::new(readme);\n        let abs_file_path = paths::normalize_path(&pkg.root().join(readme_path));\n        if abs_file_path.is_file() {\n            check_for_file_and_add(\"readme\", readme_path, abs_file_path, pkg, &mut result, ws)?;\n        } else {\n            error_on_nonexistent_file(&pkg, &readme_path, \"readme\", &mut invalid_manifest_field);\n        }\n    }\n\n    if !invalid_manifest_field.is_empty() {\n        return Err(anyhow::anyhow!(invalid_manifest_field.join(\"\\n\")));\n    }\n\n    for t in pkg\n        .manifest()\n        .targets()\n        .iter()\n        .filter(|t| t.is_custom_build())\n    {\n        if let Some(custom_build_path) = t.src_path().path() {\n            let abs_custom_build_path = paths::normalize_path(&pkg.root().join(custom_build_path));\n            if !abs_custom_build_path.is_file() || !abs_custom_build_path.starts_with(pkg.root()) {\n                error_custom_build_file_not_in_package(pkg, &abs_custom_build_path, t)?;\n            }\n        }\n    }\n\n    result.sort_unstable_by(|a, b| a.rel_path.cmp(&b.rel_path));\n","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/rust-lang/cargo/blob/495c385d0875c4ba51eb72ea0448a2d4c018b8d4/src/ops/cargo_package/mod.rs#L603-L639","documentation":"Thrown during `cargo package` or `cargo publish` when manifest metadata fields (`license-file` or `readme`) point to files that do not exist on disk. The `error_on_nonexistent_file` helper accumulates one message per missing file into `invalid_manifest_field`, and this bail joins them with newlines. The `{}` placeholder is filled by the concatenated per-field error strings.","triggerScenarios":"Calling `cargo package` or `cargo publish` on a crate whose `Cargo.toml` declares `license-file = \"LICENSE\"` or `readme = \"README.md\"` but the referenced file does not exist at the resolved path (relative to the package root). Both fields are checked sequentially; if both are missing, two messages are joined.","commonSituations":"Renaming or deleting a LICENSE/README file without updating Cargo.toml; typos in the path value; using an absolute path that works on one developer's machine but not another; restructuring a project and forgetting to update manifest metadata.","solutions":["Verify the file referenced by `license-file` or `readme` in Cargo.toml exists at the stated relative path from the package root.","Correct the path in Cargo.toml to match the actual filename (case-sensitive on Unix).","Remove the `license-file`/`readme` key from Cargo.toml if the file is no longer relevant.","Re-create the missing file if it was accidentally deleted."],"exampleFix":"// Cargo.toml (before)\nlicense-file = \"LICENCE\"\nreadme = \"README.markdown\"\n// Cargo.toml (after — match actual filenames)\nlicense-file = \"LICENSE\"\nreadme = \"README.md\"","handlingStrategy":"validation","validationCode":"// Before calling cargo package, verify referenced files exist\nuse std::path::Path;\nfn validate_manifest_files(pkg_root: &Path, license_file: Option<&str>, readme: Option<&str>) -> Result<(), String> {\n    let mut errs = Vec::new();\n    if let Some(lf) = license_file {\n        if !pkg_root.join(lf).is_file() { errs.push(format!(\"license-file `{}` not found\", lf)); }\n    }\n    if let Some(rm) = readme {\n        if !pkg_root.join(rm).is_file() { errs.push(format!(\"readme `{}` not found\", rm)); }\n    }\n    if errs.is_empty() { Ok(()) } else { Err(errs.join(\"\\n\")) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `cargo package --no-verify --list` as a pre-publish smoke test to catch missing files early.","Keep LICENSE and README filenames consistent across all crates in a workspace.","Use CI to run `cargo publish --dry-run` before merging to main."],"tags":["cargo-package","manifest","file-not-found","metadata"],"backgroundTag":null,"analyzedSha":"495c385d0875c4ba51eb72ea0448a2d4c018b8d4","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}