Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fine-grain control of Config.toml discovery #7887
Describe the problem you are trying to solve
Cargo's documented algorithm for configurations is hard to control - it searches in many places reading every config file it can find, and ultimately combines them into a single effective config.
This means that its very hard to limit where it finds config files - for example, if any parent directory happens to have a
As an example of a potential hazard, if one were trying to do an isolated build in
Currently the only sure-fire way to guarantee isolation is by using a container or some other isolation mechanism. That's excessively heavy-weight.
Describe the solution you'd like
The path elements are directories in which it searches for
This would not affect configuration from environment variables. The assumption is that they're easier to control (and since this mechanism requires an environment variable, it already relies on them being controlled).
When merging configurations, the precedence is defined by order within the path, with earlier in the path having higher precedence.