{"record":{"id":"e00d62de0e56e950","repo":"rust-lang/cargo","slug":"invalid-package-build-file-name","errorCode":null,"errorMessage":"invalid `package.build` file name","messagePattern":"invalid `package\\.build` file name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/parser/targets.rs","lineNumber":1136,"sourceCode":"                \"`build_file` started as a String and `normalize_path` shouldn't have changed that\",\n            );\n            Ok(Some(TomlPackageBuild::SingleScript(build)))\n        }\n        Some(TomlPackageBuild::Auto(true)) => {\n            Ok(Some(TomlPackageBuild::SingleScript(BUILD_RS.to_owned())))\n        }\n        Some(TomlPackageBuild::MultipleScript(scripts)) => {\n            for script in scripts {\n                validate_build_name(script)?;\n            }\n            Ok(build.cloned())\n        }\n    }\n}\n\nfn validate_build_name(build: &str) -> CargoResult<()> {\n    if Path::new(build).file_stem().is_none() {\n        anyhow::bail!(\"invalid `package.build` file name\");\n    }\n    Ok(())\n}\n\nfn name_or_panic(target: &TomlTarget) -> &str {\n    target\n        .name\n        .as_deref()\n        .unwrap_or_else(|| panic!(\"target name is required\"))\n}\n\nfn validate_lib_name(target: &TomlTarget, warnings: &mut Vec<String>) -> CargoResult<()> {\n    validate_target_name(target, TARGET_KIND_HUMAN_LIB, TARGET_KIND_LIB, warnings)?;\n    let name = name_or_panic(target);\n    if name.contains('-') {\n        anyhow::bail!(\"library target names cannot contain hyphens: {}\", name)\n    }\n","sourceCodeStart":1118,"sourceCodeEnd":1154,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/workspace/parser/targets.rs#L1118-L1154","documentation":"`validate_build_name` checks that each path in `package.build` has a non-None `file_stem()`. A path with no stem (`\"\"`, `\".\"`, `\"/\"`, trailing separator only) is meaningless as a build script name and is rejected before target generation.","triggerScenarios":"`[package] build = \"\"`, `build = \".\"`, or any value whose `Path::file_stem()` returns `None`. The guard at targets.rs:1138 fires.","commonSituations":"Empty string from a templating/env-substitution mistake. Accidentally leaving `build` with a placeholder. Misconfigured build tooling that injects an empty path.","solutions":["Set `build` to a real script path such as `\"build.rs\"`.","Remove the `build` key entirely to use the default `build.rs` convention.","Validate the path is non-empty before writing the manifest."],"exampleFix":"# before\n[package]\nbuild = \"\"\n\n# after\n[package]\nbuild = \"build.rs\"","handlingStrategy":"validation","validationCode":"fn valid_build_name(build: &str) -> bool {\n    std::path::Path::new(build).file_stem().is_some()\n}\n// reject empty/dot/slash-only values before writing the manifest","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set `build` to an empty string or placeholder.","Prefer omitting `build` to use the default `build.rs`.","Sanitize templated manifest values before rendering."],"tags":["cargo","config","build-script","validation","manifest"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}