{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreibaiysbeylolymi6shlr6hxml5tmwly7bfah53o43jiojwmh6ofqm",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mkncyf6fbxl2"
  },
  "path": "/t/pre-rfc-proposal-bound-cargos-implicit-upward-discovery-for-config-toml-files/24210#post_1",
  "publishedAt": "2026-04-29T14:32:37.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "rust-lang/cargo#9769: Cargo config search meta issue",
    "rust-lang/cargo#7887: Fine-grain control of config discovery",
    "rust-lang/cargo#7894: CARGO_CONFIG_PATH config search override PR",
    "rust-lang/cargo#7621: Ignore parent directory configs / stop paths",
    "rust-lang/cargo#8643: --ignore-local-config / isolated config mode"
  ],
  "textContent": "## Proposal: bound Cargo's implicit upward discovery\n\nCargo currently walks from cwd toward filesystem root when discovering `.cargo/config.toml`. That is useful interactively, but tools do not have a supported way to say \"only discover config inside this project/build directory\".\n\nThis affects tools like Pixi, generated build directories, `/tmp` builds, and other wrappers that can set `CARGO_HOME` but cannot prevent parent `.cargo/config.toml` from being loaded.\n\nI propose adding one discovery-boundary primitive, exposed first as an env var because wrappers need it to propagate to nested Cargo invocations:\n\n`CARGO_DISCOVERY_CEILINGS=<path-list>`\n\nFor any upward discovery starting at `cwd`, Cargo picks the nearest configured ancestor and searches only up to that directory, inclusive.\n\nWhen used for config discovery:\n\n  * load `.cargo/config.toml` from `cwd` through the active ceiling\n  * do not inspect ancestors above the ceiling\n  * do not implicitly load `$CARGO_HOME/config.toml`\n  * still allow explicit `--config <path>` and `include`\n\n\n\nThe `$CARGO_HOME` behavior matters: otherwise a tool still cannot describe the implicit config graph it is willing to load. Users who want home config can add it explicitly with `--config \"$CARGO_HOME/config.toml\"` or an `include`.\n\nThis is intended to be the config-discovery half of the same problem as workspace/package discovery ceilings. I think config discovery can be phased first, but the primitive should be designed so #7621 and #7871 do not grow separate incompatible knobs.\n\nRelated threads:\n\n  * rust-lang/cargo#9769: Cargo config search meta issue\n  * rust-lang/cargo#7887: Fine-grain control of config discovery\n  * rust-lang/cargo#7894: CARGO_CONFIG_PATH config search override PR\n  * rust-lang/cargo#7621: Ignore parent directory configs / stop paths\n  * rust-lang/cargo#8643: --ignore-local-config / isolated config mode\n\n",
  "title": "[Pre-RFC] Proposal: bound Cargo's implicit upward discovery for config.toml files"
}