{"id":"6795c1022263c1d0","repo":"rust-lang/cargo","slug":"output-of-print-request-missing-when-learning","errorCode":null,"errorMessage":"output of --print={request} missing when learning about target-specific information from rustc\n{err_info}","messagePattern":"output of --print=(.+?) missing when learning about target-specific information from rustc\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/build_context/target_info.rs","lineNumber":702,"sourceCode":"    };\n    let mut parts = line.trim().split(\"___\");\n    let prefix = parts.next().unwrap();\n    let Some(suffix) = parts.next() else {\n        return error_missing_print_output(\"file-names\", cmd, output, error);\n    };\n\n    Ok(Some((prefix.to_string(), suffix.to_string())))\n}\n\n/// Helper for creating an error message for missing output from a certain `--print` request.\nfn error_missing_print_output<T>(\n    request: &str,\n    cmd: &ProcessBuilder,\n    stdout: &str,\n    stderr: &str,\n) -> CargoResult<T> {\n    let err_info = output_err_info(cmd, stdout, stderr);\n    anyhow::bail!(\n        \"output of --print={request} missing when learning about \\\n     target-specific information from rustc\\n{err_info}\",\n    )\n}\n\n/// Helper for creating an error message when parsing rustc output fails.\nfn output_err_info(cmd: &ProcessBuilder, stdout: &str, stderr: &str) -> String {\n    let mut result = format!(\"command was: {}\\n\", cmd);\n    if !stdout.is_empty() {\n        result.push_str(\"\\n--- stdout\\n\");\n        result.push_str(stdout);\n    }\n    if !stderr.is_empty() {\n        result.push_str(\"\\n--- stderr\\n\");\n        result.push_str(stderr);\n    }\n    if stdout.is_empty() && stderr.is_empty() {\n        result.push_str(\"(no output received)\");","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/compiler/build_context/target_info.rs#L684-L720","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$ cargo build --target wasm32-unknown-unknown\nerror: output of --print=... missing when learning about target-specific information\n\n// after\n$ rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown","handlingStrategy":"validation","validationCode":"// Ensure target std component is installed before building\nlet installed = rustup_target_list_installed();\nif !installed.contains(&triple.to_string()) {\n    eprintln!(\"`{triple}` not installed; run: rustup target add {triple}\");\n}","typeGuard":"fn target_installed(triple: &str, installed: &[String]) -> bool {\n    installed.iter().any(|t| t == triple)\n}\n","tryCatchPattern":null,"preventionTips":["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."],"tags":["cargo","build","rustc","cross-compile","toolchain","target"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}