Skip to content
Latchkey

Rust E0425 "cannot find value in this scope" in CI

rustc found an identifier used as a value that does not name any binding, constant, or function in scope. The name is misspelled, never declared, or only exists under a feature that is off.

What this error means

The build fails with error[E0425]: cannot find value foo in this scope pointing at the use site. It reproduces every run from the same source.

cargo
error[E0425]: cannot find value `max_retries` in this scope
 --> src/run.rs:12:17
   |
12 |     for _ in 0..max_retries {
   |                 ^^^^^^^^^^^ not found in this scope
   |
help: a local variable with a similar name exists: `max_retry`

Common causes

Typo or undeclared binding

The value name does not match any let, const, static, or function in scope -- usually a spelling slip or a binding removed in a refactor.

Feature-gated constant or function

A const or fn compiled only under a Cargo feature is invisible when CI builds without that feature.

How to fix it

Use the name the compiler suggests

  1. Check the help: a local variable with a similar name exists hint for the intended identifier.
  2. Fix the typo, or declare the binding if it was never introduced.
  3. If the value is feature-gated, enable that feature in the CI build.
src/run.rs
let max_retries = 3;
for _ in 0..max_retries { /* ... */ }

Match the CI feature flags

Confirm the value is not hidden behind a feature your local default build enables.

Terminal
cargo check --no-default-features --features ci --locked

How to prevent it

  • Run cargo check across the same feature sets CI uses.
  • Enable editor rust-analyzer diagnostics so unresolved values surface before commit.
  • Avoid feature-gating identifiers referenced from non-gated code.

Related guides

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