Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What happens with relative pathes? #163

Closed
matthiasbeyer opened this issue Jan 6, 2021 · 6 comments
Closed

What happens with relative pathes? #163

matthiasbeyer opened this issue Jan 6, 2021 · 6 comments

Comments

@matthiasbeyer
Copy link
Collaborator

Hi.

I have a question about relative pathes in layered configuration. For example if I have the following structure:

/
/root.toml
/foo/foo.toml
/foo/bar/bar.toml
/foo/bar/somefile.txt
/baz/baz.toml
/baz/somefile.txt

And I layer my configuration objects via the nesting, so I get two configuration objects:

  1. root.toml + foo.toml + bar.toml
  2. root.toml + baz.toml

Where do I end up with a path = ./somefile.txt in baz.toml? The PathBuf deserialized does not point to the right file, does it?
And I cannot find it after deserializing the objects because

  1. I don't know which file the setting came from, so I cannot search relative to that files directory
  2. If I would search the tree, foo/bar/somefile.txt would be found first, which is obviously wrong

Is there a strategy to handle such cases? Is there a way to make config-rs handle relative pathes?
I think it is in the scope of this crate and would love to see such a feature, even contribute code for it.

@matthiasbeyer
Copy link
Collaborator Author

Hi @mehcode any thoughts on this?

@matthiasbeyer
Copy link
Collaborator Author

I'm still interested in this.

@matthiasbeyer
Copy link
Collaborator Author

Hi.

This gets more and more relevant for me. I'm thinking about implementing it myself for this library, if it is okay with you to include such a change. I have to talk to my employer first, though, whether I can implement this on company time.
Still: Would you merge such a feature?

@fpoli
Copy link

fpoli commented Feb 18, 2021

You could try contacting the other maintainers mentioned here: #149 (comment)

@matthiasbeyer
Copy link
Collaborator Author

Yeah, I'll do that.
I'll use the shotgun approach: @dawid-nowak @eisterman @ignatenkobrain @joelgallant @LukeMathWalker @szarykott @up9cloud @vmalloc

@matthiasbeyer
Copy link
Collaborator Author

So, as the crate does not necessarily know about PathBufs, we cannot handle them in the codebase of this crate. Though, I was able to solve my usecase via the newly introduced Config::set_once() function (if anyone is interested how, see this scope, or if that is too complicated shoot me an email 😄 ).

I'll close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants