{"id":"3f1ac8f5f36d8bb2","repo":"rust-lang/cargo","slug":"metabuild-package-must-be-specified-in-build","errorCode":null,"errorMessage":"metabuild package `{}` must be specified in `build-dependencies`","messagePattern":"metabuild package `(.+?)` must be specified in `build-dependencies`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/parser/targets.rs","lineNumber":129,"sourceCode":"                \"build-script-{}\",\n                script_path\n                    .file_stem()\n                    .and_then(|s| s.to_str())\n                    .expect(\"previously normalized\")\n            );\n            targets.push(Target::custom_build_target(\n                &name,\n                package_root.join(script_path),\n                edition,\n            ));\n        }\n    }\n    if let Some(metabuild) = metabuild {\n        // Verify names match available build deps.\n        let bdeps = normalized_toml.build_dependencies.as_ref();\n        for name in &metabuild.0 {\n            if !bdeps.map_or(false, |bd| bd.contains_key(name.as_str())) {\n                anyhow::bail!(\n                    \"metabuild package `{}` must be specified in `build-dependencies`\",\n                    name\n                );\n            }\n        }\n\n        targets.push(Target::metabuild_target(&format!(\n            \"metabuild-{}\",\n            package.normalized_name().expect(\"previously normalized\")\n        )));\n    }\n\n    Ok(targets)\n}\n\n#[tracing::instrument(skip_all)]\npub fn normalize_lib(\n    original_lib: Option<&TomlLibTarget>,","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/parser/targets.rs#L111-L147","documentation":"Error \"metabuild package `{}` must be specified in `build-dependencies`\" thrown in rust-lang/cargo.","triggerScenarios":"Thrown at src/workspace/parser/targets.rs:129 when the library encounters an invalid state.","commonSituations":"Occurs when `metabuild` names a package that is not listed in `[build-dependencies]`. Add the metabuild package to `[build-dependencies]` in Cargo.toml.","solutions":["Add the metabuild package to `[build-dependencies]` in Cargo.toml so it is available at build time.","Remove the `metabuild` key if the package is not meant to be a metabuild dependency."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}