rust-lang/cargo · error · anyhow::Error
found build scripts with duplicate file stems, but all build
Error message
found build scripts with duplicate file stems, but all build scripts must have a unique file stem
What it means
Error "found build scripts with duplicate file stems, but all build scripts must have a unique file stem" thrown in rust-lang/cargo.
Source
Thrown at src/workspace/parser/targets.rs:928
.file_stem()
.and_then(|s| s.to_str())
.expect("previously normalized");
seen.entry(stem)
.or_insert_with(Vec::new)
.push(script.as_str());
}
let mut conflict_file_stem = false;
let mut err_msg = String::from(
"found build scripts with duplicate file stems, but all build scripts must have a unique file stem",
);
for (stem, paths) in seen {
if paths.len() > 1 {
conflict_file_stem = true;
write!(&mut err_msg, "\n for stem `{stem}`: {}", paths.join(", "))?;
}
}
if conflict_file_stem {
anyhow::bail!(err_msg);
}
Ok(())
}
fn configure(
toml: &TomlTarget,
target: &mut Target,
target_kind_human: &str,
warnings: &mut Vec<String>,
) -> CargoResult<()> {
let t2 = target.clone();
target
.set_tested(toml.test.unwrap_or_else(|| t2.tested()))
.set_doc(toml.doc.unwrap_or_else(|| t2.documented()))
.set_doctest(toml.doctest.unwrap_or_else(|| t2.doctested()))
.set_benched(toml.bench.unwrap_or_else(|| t2.benched()))
.set_harness(toml.harness.unwrap_or_else(|| t2.harness()))
.set_proc_macro(toml.proc_macro().unwrap_or_else(|| t2.proc_macro()))View on GitHub (pinned to 0e07a15537)
Solutions
- Rename one of the build script files so their file stems are unique.
- Point `build = "..."` at distinct script paths for each package.
When it happens
Trigger: Thrown at src/workspace/parser/targets.rs:928 when the library encounters an invalid state.
Common situations: Occurs when multiple build scripts share the same file stem (e.g. `build.rs` and `build/main.rs` both stemming to `build`). Rename build script files so their stems are unique.
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/0a896bf0fae96852.json.
Report an issue: GitHub.