Searching for configuration file in parent directories
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
I use this pattern to load my config file
Config::builder()
.add_source(File::with_name(".myconfig"))
.build()?
.try_deserialize::<MyConfig>()
By default this only picks up a config file in the current directory, but I'm hoping to be able to run my program anywhere within a project that has ".myconfig" in the root directory. Is there a preferred way to do this?
My first thought is to successively ConfigBuilder::build in each parent directory up to / every time ConfigError::NotFound occurs; but that seems pretty naive
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Config::builder, File::with_name, ConfigBuilder::build, and ConfigError::NotFound to understand the current file lookup behavior. Determine how parent-directory discovery should work and what tests or documentation would demonstrate that a .myconfig file is found when running from a project subdirectory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100