CARGO_FIX_MAX_RETRIES env var is missing from the docs

Open Beginner friendly
#17,342 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
82/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
cli, documentation

Research direction

Start with environment-variables.md and the "Environment variables Cargo reads" section; use src/ops/cargo_fix/mod.rs around line 914 to confirm the variable's behavior and default. Done means the documentation explains CARGO_FIX_MAX_RETRIES, its retry limit, and the default of 4, with an optional cargo-fix documentation mention if that scope is accepted.

Written by the indexing model from the issue text.

Description

Command-fix

summary

cargo fix doesn't apply suggestions in a single pass — it re-runs the compiler and re-applies fixes in a loop, because fixing one warning can often expose another one underneath it. To keep this from running forever, it stops after 4 iterations by default.

That limit is actually configurable. There's an env var for it already sitting in the code:

let max_iterations = gctx
.get_env("CARGO_FIX_MAX_RETRIES")
.ok()
.and_then(|n| n.parse().ok())
.unwrap_or(4);
src/ops/cargo_fix/mod.rs, around line 914.

.But it's never been written down anywhere, not in environment-variables.md, If you didn't already know this variable exists, the only way to find out is to go read the source.

fix

add CARGO_FIX_MAX_RETRIES to the "Environment variables Cargo reads" section of environment-variables.md, describing what it does and that the default is 4. Might be worth a short mention in the cargo-fix docs as well, since that's probably where someone debugging this would look first.

Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
1d 8h
Merged PRs (30d)
55

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/cargo

All issues in rust-lang/cargo

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.