{"record":{"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":733,"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":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/compiler/build_context/target_info.rs#L715-L751","documentation":"Cargo invokes `rustc --print=<request>` (e.g. `file-names`, `sysroot`, `target-list`) to gather target-specific data, and the expected output line was entirely absent. `error_missing_print_output` formats the command and its stdout/stderr for diagnosis.","triggerScenarios":"Any `rustc --print=...` invocation that returns no matching output: missing `--print` support in an old/custom rustc, a malformed custom target JSON, or a wrapper that strips rustc stdout during probing.","commonSituations":"Using a heavily patched or pre-1.0 rustc; custom target specs (`--target foo.json`) that don't expose required keys; CI images where rustc is a shim; `RUSTC_WRAPPER` interfering with `--print` queries.","solutions":["Inspect `err_info` in the message: run the printed `command was:` line manually to see rustc's actual response.","Update the toolchain: `rustup update stable`.","Remove `RUSTC_WRAPPER`/`RUSTC_WORKSPACE_WRAPPER` and retry.","Validate custom target JSON against the schema; fall back to a built-in target to confirm."],"exampleFix":"// before\nRUSTC_WRAPPER=cache-build cargo build\n\n// after\nunset RUSTC_WRAPPER\ncargo build\n# then run the failing --print command by hand:\n# rustc --print=file-names --target <triple>","handlingStrategy":"validation","validationCode":"fn rustc_supports_print(request: &str) -> bool {\n    let out = std::process::Command::new(\"rustc\").arg(format!(\"--print={request}\")).output();\n    matches!(out, Ok(o) if o.status.success() && !o.stdout.is_empty())\n}","typeGuard":"null","tryCatchPattern":"match learn_target_info(request) {\n    Err(e) if e.to_string().contains(\"output of --print\") => fallback_builtin_target_info()?,\n    r => r?,\n}","preventionTips":["Sanity-check rustc with `rustc --print=sysroot` in CI boot.","Avoid `RUSTC_WRAPPER` shims that swallow stdout.","Keep custom target specs minimal and conform to the schema."],"tags":["cargo","rustc","print","toolchain","target"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}