{"id":"973c3b20f43f27ae","repo":"rust-lang/cargo","slug":"previously-normalized","errorCode":null,"errorMessage":"previously normalized","messagePattern":"previously normalized","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_vendor.rs","lineNumber":543,"sourceCode":"        gctx,\n        &mut warnings,\n        &mut errors,\n    )?;\n    let new_pkg = Package::new(manifest, me.manifest_path());\n    Ok(new_pkg)\n}\n\nfn prepare_toml_for_vendor(\n    mut me: cargo_util_schemas::manifest::TomlManifest,\n    packaged_files: &[PathBuf],\n    gctx: &GlobalContext,\n) -> CargoResult<cargo_util_schemas::manifest::TomlManifest> {\n    let package = me\n        .package\n        .as_mut()\n        .expect(\"venedored manifests must have packages\");\n    // Validates if build script file is included in package. If not, warn and ignore.\n    if let Some(custom_build_scripts) = package.normalized_build().expect(\"previously normalized\") {\n        let mut included_scripts = Vec::new();\n        for script in custom_build_scripts {\n            let path = paths::normalize_path(Path::new(script));\n            let included = packaged_files.contains(&path);\n            if included {\n                let path = path\n                    .into_os_string()\n                    .into_string()\n                    .map_err(|_err| anyhow::format_err!(\"non-UTF8 `package.build`\"))?;\n                let path = crate::workspace::parser::normalize_path_string_sep(path);\n                included_scripts.push(path);\n            } else {\n                gctx.shell().warn(format!(\n                    \"ignoring `package.build` entry `{}` as it is not included in the published package\",\n                    path.display()\n                ))?;\n            }\n        }","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_vendor.rs#L525-L561","documentation":"Invariant immediately after 309: `package.normalized_build().expect(\"previously normalized\")`. The vendoring pipeline normalizes the `[package]` table earlier, so `normalized_build()` (which returns `Result`) should not error here. The expect guards the assumption that build-script normalization already happened.","triggerScenarios":"Fires only if `normalized_build()` fails on a `[package]` table that was supposed to have been normalized upstream — e.g. a `build = \"...\"` key shaped in a way the normalizer accepts but the re-normalizer rejects, or a manifest mutated between normalization and this call.","commonSituations":"Cargo bug in the vendor manifest-preparation pipeline; a `[package].build` value (string vs. table) inconsistent between the original and prepared manifest; regression after changes to `TomlPackage::normalized_build`. End users rarely hit this directly.","solutions":["Inspect the `[package].build` key of the crate being vendored (`cargo vendor -v`) for an unusual shape.","Report a cargo bug with the offending manifest attached.","As a workaround, simplify `build = { path = \"...\" }` to `build = \"...\"` (or vice-versa) in the source manifest if you control it."],"exampleFix":"// before\nif let Some(custom_build_scripts) = package.normalized_build().expect(\"previously normalized\") {\n\n// after\nif let Some(custom_build_scripts) = package.normalized_build()\n    .with_context(|| \"failed to re-normalize [package].build during vendoring\")? {","handlingStrategy":"validation","validationCode":"// Validate [package].build shape before vendoring.\nmatch &pkg.build {\n    Some(toml_edit::Item::Value(_)) | Some(toml_edit::Item::Table(_)) | None => {},\n    other => return Err(anyhow!(\"[package].build has unexpected shape: {:?}\", other)),\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the canonical `build = \"build.rs\"` form in manifests you control.","Keep cargo updated so vendor normalization stays consistent."],"tags":["cargo","panic","invariant","cargo-vendor","build-script","manifest","rust"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}