-
Notifications
You must be signed in to change notification settings - Fork 967
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
include file()
is not relative to the file doing the including
#202
Comments
http://typesafehub.github.io/config/latest/api/com/typesafe/config/ConfigIncluder.html exists, but I don't have a good example to point to. The general outline of how this works is that you set an includer on your ConfigParseOptions, then the library is going to call |
After a few tries to get what you said to work, I have figured out a solution that seems to work for what I wanted.
instead of 'include file("plugins/[plugin name]/foo.conf")' I can use 'include "foo.conf"'
Thanks for your input |
That looks right to me. If you wanted to chain to the regular default includer, you would add a field There are also extra interfaces for implementing file() etc if I remember right. ConfigIncluderFile etc. |
I am unsure what I missed, but I tested it with and without the includer I made and 'include "foo.conf"' seems to do exactly what I want in both cases. (that is look for 'foo.conf' relative to the file the 'include' was found in) I have to be missing something, if this is the case then I never needed to make a custom includer in the first place. It could be that I always used 'include file("foo.conf")' before and never tried it without the file(). Am I missing something? |
https://github.com/typesafehub/config/blob/master/HOCON.md#include-semantics-locating-resources is how it's supposed to work (maybe it even does!) Yes, foo.conf is supposed to be found relative to the file that included foo.conf. I apologize for not catching right away that's what you were doing. According to the spec this does appear to be only if it's bare The spec is a little unclear even to me; it says the bare I guess the first step is to figure out what the current code actually does and whether we have tests for it. Then we can figure out how to clarify the spec. The spec may end up having to document whatever the code does, unless the code is doing something utterly useless that nobody could be relying on. If I put a
None of those sound like they are directly testing this feature in normal usage, though, so I wouldn't say we've proven it works. |
include file()
is not relative to the file doing the including
At present, we don't make a file() include relative to the file doing the including. This is discussed in #202. We should most likely change this behavior, but this commit documents and tests it.
At present, we don't make a file() include relative to the file doing the including. This is discussed in #202. We should most likely change this behavior, but this commit documents and tests it.
I added PR #277 which tests and documents the current behavior. Right now only the "heuristic" includes (without file()) do the "look adjacent" trick. I think we should probably change this, though it would technically be a semantic ABI break. But the code needs to be reshuffled a bit to make this change, it isn't 100% trivial. In the meantime the situation is "works as designed, but design decision was kinda bad." |
any updates on this? |
No idea offhand. I guess you are trying a thing like |
After a bunch of attempts, I'm fairly certain that |
Referencing a local path is not working as follows: For the following configuratoin:
This works if the above snippet is directly inside the calling file - but gives the following error if using the following include directive: include "matching-sqls.conf"
I am fine to do any kind of relative or local path for includes - but is anything working presently? |
I've found traversing the whole resource path easier to include a file from parent directory Let's say you have |
This is a major bug that my project cannot live with, since we'd like all our include paths to be relative within a git repository. Here is an easy way to reproduce the bug:
|
Is there even a reasonable workaround? I think bare |
When writing plugins for Bukkit, the plugin's data folder is located at "plugins/[plugin name]".
In order to make use of "include file()" I must enter in that entire path before hand such that it looks like this "foo = { include file("plugins/[plugin name]/bar.conf }. I want the include to implicitly assume the "plugins/<plugin name/" to keep my config files clean.
I have have a feeling It can be done by implementing "ConfigIncluder" but I have not figured out how to do this.
The text was updated successfully, but these errors were encountered: