Updates

Cargo pre-RFC proposes discovery ceilings for config file search

Cargo may soon stop wandering up parent directories for config, giving wrappers a hard ceiling that keeps temp builds from inheriting stray .cargo/config.toml files.

Nina Kowalski··2 min read
Published
Listen to this article0:00 min
Cargo pre-RFC proposes discovery ceilings for config file search
Source: miro.medium.com

Cargo’s automatic climb up the filesystem has always been a convenience for interactive work, but it has also made configuration feel a little too ambient for tools that want clean, repeatable builds. A pre-RFC posted on April 29, 2026, on Rust Internals proposed a new boundary primitive, `CARGO_DISCOVERY_CEILINGS=<path-list>`, so wrappers can tell Cargo exactly how far it may search upward for config before it stops.

That tradeoff sits at the center of the proposal. Today Cargo searches for `.cargo/config.toml` in the current directory and all parent directories, then merges what it finds with the global config. It also still accepts the older `.cargo/config`, while `.cargo/config.toml` support, added in Cargo 1.39, is the preferred form. For someone working inside a project tree, that upward walk can be handy. For generated build directories, wrapper environments, CI scratch spaces, and temporary paths, it can also mean a parent `.cargo/config.toml` is picked up silently when nobody intended it.

AI-generated illustration
AI-generated illustration

The author argued that tools can already set `CARGO_HOME`, but that does not solve the larger problem of accidental parent-directory inheritance. The ceiling would let Cargo load configuration only between the working directory and a chosen ancestor, while still honoring explicit ` config <path>` arguments and explicit `include` relationships. That distinction matters: the goal is to preserve deliberate configuration, not the hidden kind that leaks in from someplace above `/tmp/mybuild-XXXX` or another scratch directory.

The safety concern is not theoretical. A 2020 Cargo issue warned that a random temp build could be affected by `/tmp/.cargo/config.toml`, and a 2023 issue showed Cargo loading `~/.cargo/config.toml` even with `CARGO_HOME` set, because the working directory lived under `$HOME`. A 2021 meta issue also said Cargo’s config search had “very little control” and could be confusing or surprising. Another 2024 report said `cargo install` did not load a workspace `.cargo/config.toml`, underscoring how uneven config discovery has become across subcommands.

The new thread tied those frustrations together with older design ideas, including a 2020 proposal for `CARGO_CONFIG_PATH` and later efforts around ignoring parent configs, isolated config mode, and search overrides. One commenter said they would like “only look in cwd” to become the default in a future edition, while another suggested an `.editorconfig`-style `root = true` switch. The author pushed back on that approach, saying wrappers need the boundary to come from outside the discovered config graph.

That makes the proposal more than a niche tweak. Rust-analyzer already models Cargo project discovery and reads `.cargo/config.toml`, so any change to search semantics could ripple into editor tooling too. If the idea moves forward, Cargo would gain a cleaner way to sandbox builds without stripping away the ergonomics that make parent-directory discovery useful in ordinary day-to-day work.

This article was produced by Prism’s automated news system from verified source data, official records, and press releases, then run through automated quality and moderation checks before publishing. The system is built and supervised by the people who set the standards it runs under. Read our full AI policy.

Did this article answer your question?

Discussion

More Rust Programming News

Cargo pre-RFC proposes discovery ceilings for config file search | Prism News