rust-lang/cargo · error
failed to find rmeta dep for pipelined dep
Error message
failed to find rmeta dep for pipelined dep
What it means
When passing `--extern` for a pipelined dependency that only needs metadata, Cargo finds the `FileFlavor::Rmeta` output via `.find(...).expect("failed to find rmeta dep for pipelined dep")`. A dependency whose edge is `only_requires_rmeta` (or in check mode) is expected to have produced an `.rmeta` file; absence means the outputs list contains no Rmeta-flavored entry.
Source
Thrown at src/compiler/mod.rs:1858
}
value.push(extern_crate_name.as_str());
value.push("=");
let mut pass = |file| {
let mut value = value.clone();
value.push(file);
result.push(OsString::from("--extern"));
result.push(value);
};
let outputs = build_runner.outputs(&dep.unit)?;
if build_runner.only_requires_rmeta(unit, &dep.unit) || dep.unit.mode.is_check() {
// Example: rlib dependency for an rlib, rmeta is all that is required.
let output = outputs
.iter()
.find(|output| output.flavor == FileFlavor::Rmeta)
.expect("failed to find rmeta dep for pipelined dep");
pass(&output.path);
} else {
// Example: a bin needs `rlib` for dependencies, it cannot use rmeta.
for output in outputs.iter() {
if output.flavor == FileFlavor::Linkable {
pass(&output.path);
}
// If we use -Zembed-metadata=no, we also need to pass the path to the
// corresponding .rmeta file to the linkable artifact, because the
// normal dependency (rlib) doesn't contain the full metadata.
else if no_embed_metadata && output.flavor == FileFlavor::Rmeta {
pass(&output.path);
}
}
}
Ok(())
};
View on GitHub (pinned to 0e07a15537)
Solutions
- `cargo clean` then rebuild — corrupted/incomplete pipelined outputs are the usual cause.
- Disable pipelined compilation temporarily (`CARGO_BUILD_PIPELINED=false`) to confirm, then re-enable after a clean.
- Free disk space and ensure no process deletes from `target/`.
Example fix
// before
let output = outputs
.iter()
.find(|output| output.flavor == FileFlavor::Rmeta)
.expect("failed to find rmeta dep for pipelined dep");
// after
let output = outputs
.iter()
.find(|output| output.flavor == FileFlavor::Rmeta)
.ok_or_else(|| anyhow::anyhow!("pipelined dep `{}` produced no .rmeta output", dep.unit.pkg.package_id()))?; Defensive patterns
Strategy: validation
Validate before calling
// Confirm pipelined rmeta files exist before incremental builds
fn pipelined_rmeta_present(deps: &std::path::Path) -> bool {
deps.read_dir().map(|mut it| it.any(|e| e.ok()
.and_then(|e| e.path().extension().and_then(|s| s.to_str()).map(|s| s == "rmeta"))
.unwrap_or(false))).unwrap_or(false)
} Prevention
- `cargo clean` after switching rustc or toggling pipelined compilation.
- Set `CARGO_BUILD_PIPELINED=false` to diagnose, then re-enable after a clean.
- Free disk space; keep external tools out of `target/`.
When it happens
Trigger: A pipelined compilation whose upstream unit did not emit an rmeta (rustc crashed, was killed, or run with a mode that suppresses rmeta) while the downstream unit was scheduled as if it had; switching rustc versions across a partial build where rmeta-emission rules changed; target-dir tampering removing the rmeta file after outputs were computed.
Common situations: Interrupted build resumed without `cargo clean`; concurrent `cargo`/`rm` on `target/`; disk-full mid-build; mixing pipelined vs non-pipelined builds across toolchain changes.
Related errors
- failed to find rmeta
- required(true)
- a file should always have a parent
- already loaded without errors
- set_verify_owner_validation should never fail
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/1f12eebb5a0afb8d.json.
Report an issue: GitHub.