rust-lang/cargo · error · anyhow::Error
no timing data found in log
Error message
no timing data found in log
What it means
Inside prepare_context, `cargo report timings` collects timing records per build unit. When the log parses but contains zero units (error_if_no_units is true for the report path), it bails at timings.rs:351. Unlike the live `--timings` flag (which happily renders an empty report), the report command treats a unit-less log as corrupted/truncated, per rust-lang/cargo#17212.
Source
Thrown at src/ops/cargo_report/timings.rs:351
e.get_mut().data.duration = elapsed;
e.get_mut().data.unblocked_units = unblocked;
}
Entry::Vacant(_) => {
tracing::warn!("unit {index} ended, but it has no start recorded");
}
},
_ => {} // skip non-timing logs
}
}
// A build can legitimately have no units at all, such as an idle
// `cargo test` with `test = false` and `doctest = false`,
// so `--timings` always renders its report.
// `cargo report timings` instead treats a unit-less
// log as corrupted or truncated and errors out.
// See https://github.com/rust-lang/cargo/issues/17212.
if error_if_no_units && units.is_empty() {
anyhow::bail!("no timing data found in log");
}
ctx.root_units = {
let mut root_map: IndexMap<_, Vec<_>> = IndexMap::default();
for index in requested_units {
let unit = &units[&index];
// Pretty much like `workspace::Target::description_named`
let target_desc = if unit.target.kind == "lib" {
"lib".to_owned()
} else if unit.target.kind == "build-script" {
"build script".to_owned()
} else {
format!(r#" {} "{}""#, unit.target.name, unit.target.kind)
};
root_map.entry(index).or_default().push(target_desc);
}
root_map
.into_iter()View on GitHub (pinned to 0e07a15537)
Solutions
- Re-run a real build with `-Z build-analysis` that actually compiles units, then report against that session.
- Use `cargo report sessions` to pick a session known to have done work.
- If the log is corrupted, delete it from the log directory and regenerate.
Example fix
# before - report against an idle session $ cargo report timings --id <idle-id> error: no timing data found in log # after - build something then report $ cargo +nightly build -Z build-analysis $ cargo +nightly report timings
Defensive patterns
Strategy: validation
Validate before calling
# Heuristic: reject obviously empty/truncated logs (no timing records): log="$1" if ! grep -q '"kind"' "$log" 2>/dev/null; then echo "log has no build-unit records; rebuild with -Z build-analysis" >&2 exit 1 fi cargo report timings --id "$(basename "$log")"
Prevention
- Report against a session that actually compiled units.
- Use `cargo report sessions` to pick a non-idle --id.
- Delete corrupted/partial logs and regenerate with a fresh build.
When it happens
Trigger: Running `cargo report timings` against a log from a build that compiled nothing (e.g. `cargo test` with test=false and doctest=false), or a log that was truncated/corrupted mid-write.
Common situations: Pointing --id at an idle/no-op build session; cargo crashed mid-build leaving a partial log; log file manually edited.
Related errors
- no sessions found{context}
- no sessions found{context}
- no sessions found{context}
- artifact-dir was not locked
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/88f71d8ccccb82af.json.
Report an issue: GitHub.