rust-lang/cargo · error
output of --print={request} missing when learning about targ
Error message
output of --print={request} missing when learning about target-specific information from rustc
{err_info} What it means
error_missing_print_output (target_info.rs:694-706) is invoked when Cargo queries rustc with `--print=<request>` (e.g. `--print=file-names`, `--print=sysroot`, `--print=cfg`) and the expected output section is absent. Cargo expects specific print output to learn target-specific information; missing output means rustc did not provide it.
Source
Thrown at src/compiler/build_context/target_info.rs:702
};
let mut parts = line.trim().split("___");
let prefix = parts.next().unwrap();
let Some(suffix) = parts.next() else {
return error_missing_print_output("file-names", cmd, output, error);
};
Ok(Some((prefix.to_string(), suffix.to_string())))
}
/// Helper for creating an error message for missing output from a certain `--print` request.
fn error_missing_print_output<T>(
request: &str,
cmd: &ProcessBuilder,
stdout: &str,
stderr: &str,
) -> CargoResult<T> {
let err_info = output_err_info(cmd, stdout, stderr);
anyhow::bail!(
"output of --print={request} missing when learning about \
target-specific information from rustc\n{err_info}",
)
}
/// Helper for creating an error message when parsing rustc output fails.
fn output_err_info(cmd: &ProcessBuilder, stdout: &str, stderr: &str) -> String {
let mut result = format!("command was: {}\n", cmd);
if !stdout.is_empty() {
result.push_str("\n--- stdout\n");
result.push_str(stdout);
}
if !stderr.is_empty() {
result.push_str("\n--- stderr\n");
result.push_str(stderr);
}
if stdout.is_empty() && stderr.is_empty() {
result.push_str("(no output received)");View on GitHub (pinned to 0e07a15537)
Solutions
- Install the target's std component: `rustup target add <triple>`.
- Align Cargo and rustc versions (run `cargo --version` and `rustc --version`).
- Disable/upgrade rustc wrappers (`RUSTC_WRAPPER`, `RUSTC_WORKSPACE_WRAPPER`).
- Use `cargo build -v` to see the exact rustc invocation and its raw output.
Example fix
// before $ cargo build --target wasm32-unknown-unknown error: output of --print=... missing when learning about target-specific information // after $ rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown
Defensive patterns
Strategy: validation
Validate before calling
// Ensure target std component is installed before building
let installed = rustup_target_list_installed();
if !installed.contains(&triple.to_string()) {
eprintln!("`{triple}` not installed; run: rustup target add {triple}");
} Type guard
fn target_installed(triple: &str, installed: &[String]) -> bool {
installed.iter().any(|t| t == triple)
}
Prevention
- Run `rustup target add <triple>` in CI before cross-compiling.
- Keep Cargo and rustc versions aligned via rust-toolchain.toml.
- Avoid rustc wrappers that drop --print output.
When it happens
Trigger: Calling rustc with `--print` for target info and the requested field is not in the output; using a rustc version that does not support a `--print` key Cargo expects; a rustc wrapper that strips print output; an unloaded/missing target component.
Common situations: Cross-compiling to a target whose rust-std component is not installed (`rustup target add`); a rustc wrapper (sccache, build-std driver) that swallows some print output; mixing a newer Cargo with an older rustc.
Related errors
- could not find specification for target `{target}`. Depend
- malformed output when learning about crate-type {} informati
- cannot produce {} for `{}` as the target `{}` does not suppo
- cannot compile `{}` as the target `{}` does not support any
- rustc load ok
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/6795c1022263c1d0.json.
Report an issue: GitHub.