rust-lang/cargo · error
output of --print= missing when learning about…
Error message
output of --print={request} missing when learning about target-specific information from rustc
{err_info} What it means
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.
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.
Example fix
// before RUSTC_WRAPPER=cache-build cargo build // after unset RUSTC_WRAPPER cargo build # then run the failing --print command by hand: # rustc --print=file-names --target <triple>
Defensive patterns
Strategy: validation
Validate before calling
fn rustc_supports_print(request: &str) -> bool {
let out = std::process::Command::new("rustc").arg(format!("--print={request}")).output();
matches!(out, Ok(o) if o.status.success() && !o.stdout.is_empty())
} Type guard
null
Try / catch
match learn_target_info(request) {
Err(e) if e.to_string().contains("output of --print") => fallback_builtin_target_info()?,
r => r?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- malformed output when learning about crate-type
- cannot compile ` ` as the target ` ` does not support any…
- cannot produce for ` ` as the target ` ` does not support…
- could not find specification for target
- does not exist, unable to build with the standard library…
AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11).
Data as JSON: /api/errors/6795c1022263c1d0.
Report an issue: GitHub.
Appendix: source
Thrown at src/compiler/build_context/target_info.rs:733
};
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 98a09e7e7d)