{"id":"1f12eebb5a0afb8d","repo":"rust-lang/cargo","slug":"failed-to-find-rmeta-dep-for-pipelined-dep","errorCode":null,"errorMessage":"failed to find rmeta dep for pipelined dep","messagePattern":"failed to find rmeta dep for pipelined dep","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/mod.rs","lineNumber":1858,"sourceCode":"        }\n        value.push(extern_crate_name.as_str());\n        value.push(\"=\");\n\n        let mut pass = |file| {\n            let mut value = value.clone();\n            value.push(file);\n            result.push(OsString::from(\"--extern\"));\n            result.push(value);\n        };\n\n        let outputs = build_runner.outputs(&dep.unit)?;\n\n        if build_runner.only_requires_rmeta(unit, &dep.unit) || dep.unit.mode.is_check() {\n            // Example: rlib dependency for an rlib, rmeta is all that is required.\n            let output = outputs\n                .iter()\n                .find(|output| output.flavor == FileFlavor::Rmeta)\n                .expect(\"failed to find rmeta dep for pipelined dep\");\n            pass(&output.path);\n        } else {\n            // Example: a bin needs `rlib` for dependencies, it cannot use rmeta.\n            for output in outputs.iter() {\n                if output.flavor == FileFlavor::Linkable {\n                    pass(&output.path);\n                }\n                // If we use -Zembed-metadata=no, we also need to pass the path to the\n                // corresponding .rmeta file to the linkable artifact, because the\n                // normal dependency (rlib) doesn't contain the full metadata.\n                else if no_embed_metadata && output.flavor == FileFlavor::Rmeta {\n                    pass(&output.path);\n                }\n            }\n        }\n        Ok(())\n    };\n","sourceCodeStart":1840,"sourceCodeEnd":1876,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/compiler/mod.rs#L1840-L1876","documentation":"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.","triggerScenarios":"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.","commonSituations":"Interrupted build resumed without `cargo clean`; concurrent `cargo`/`rm` on `target/`; disk-full mid-build; mixing pipelined vs non-pipelined builds across toolchain changes.","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/`."],"exampleFix":"// before\nlet output = outputs\n    .iter()\n    .find(|output| output.flavor == FileFlavor::Rmeta)\n    .expect(\"failed to find rmeta dep for pipelined dep\");\n// after\nlet output = outputs\n    .iter()\n    .find(|output| output.flavor == FileFlavor::Rmeta)\n    .ok_or_else(|| anyhow::anyhow!(\"pipelined dep `{}` produced no .rmeta output\", dep.unit.pkg.package_id()))?;","handlingStrategy":"validation","validationCode":"// Confirm pipelined rmeta files exist before incremental builds\nfn pipelined_rmeta_present(deps: &std::path::Path) -> bool {\n    deps.read_dir().map(|mut it| it.any(|e| e.ok()\n        .and_then(|e| e.path().extension().and_then(|s| s.to_str()).map(|s| s == \"rmeta\"))\n        .unwrap_or(false))).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["`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/`."],"tags":["cargo","pipelined","rmeta","extern","internal-invariant"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}