Skip to content
Latchkey

Rust "cargo llvm-cov" Coverage Failures in CI

cargo llvm-cov couldn’t produce a coverage report - usually the llvm-tools-preview rustup component is missing, no instrumented profile data was generated, or a configured coverage threshold wasn’t met and the gate failed.

What this error means

A coverage step fails with a missing llvm-tools-preview/llvm-profdata error, "no profraw files found", or a threshold message like coverage 71% is below the required 80%. Tests themselves may pass; the coverage tooling or gate is what fails.

cargo output
error: failed to find llvm-profdata
note: the `llvm-tools-preview` component may not be installed
help: run `rustup component add llvm-tools-preview`

# or
error: coverage 71.4% is below the fail-under threshold of 80%

Common causes

llvm-tools-preview not installed

cargo-llvm-cov uses llvm-profdata/llvm-cov from the llvm-tools-preview rustup component. Without it, instrumentation and report generation can’t run.

No profile data or an unmet threshold

If the build wasn’t instrumented (or env got reset between steps), there’s no .profraw data to merge. Alternatively, the coverage is real but below the --fail-under threshold, which fails by design.

How to fix it

Install the component and run via the plugin

Add llvm-tools-preview and let cargo-llvm-cov set the instrumentation env itself.

Terminal
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov --locked
cargo llvm-cov --workspace --lcov --output-path lcov.info

Fix instrumentation or adjust the threshold honestly

  1. Run all tests under cargo llvm-cov (don’t split instrumented build and test across steps that reset env).
  2. If the gate is failing on a real shortfall, add tests rather than silently lowering --fail-under.
  3. Use --no-clean/--no-report correctly if you split collection and reporting.

How to prevent it

  • Install llvm-tools-preview (via the setup action’s components) wherever coverage runs.
  • Run instrumentation and tests through cargo-llvm-cov in one step so env is consistent.
  • Treat a missed coverage threshold as a signal to add tests, not to lower the bar.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →