External Publication
Visit Post

[Pre-RFC] Proposal: bound Cargo's implicit upward discovery for config.toml files

Rust Internals [Unofficial] April 30, 2026
Source

The problem is that most sources will be somewhere in $HOME: That is typically the one place users are allowed to place persistent files. So $HOME/.cargo/config.toml will be picked up by walking upward from the project's Cargo.toml. This is the case even when setting $CARGO_HOME to point somewhere else and of the current working directory.

This is typically great way for a user to override settings she wants applied to all her projects. But it is a real problem when you want a reproducible way to build the exact same configuration across different machines.

We can not place files outside the source directory we are trying to build: That is not "our" directory anymore, and no tool should litter in unexpected places. Having some environment variable would be the most convenient for our use case.

I might have misunderstood what you meant though:

I tired

cd /tmp && cargo install --path="$HOME/some/where" --root="..."

... and get a build failure due to config options I set in my ~/.cargo/config.toml.

Cargo install does not accept --manifest-path, so maybe I am doing something wrong?

Discussion in the ATmosphere

Loading comments...