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

the include command causes an error #98

Closed
dvhwgumby opened this issue Jan 16, 2018 · 11 comments
Closed

the include command causes an error #98

dvhwgumby opened this issue Jan 16, 2018 · 11 comments

Comments

@dvhwgumby
Copy link

dvhwgumby commented Jan 16, 2018

Hi folks,

If I try to parse a .conf file with an include directive I get the error Error: reader() should not be called on resources

I am calling hocon::program_options::parse_file(filename, reasoner_options, true);

I'm running on MacOS.

Also I'm not sure how to specify the search directories for "include" though at the moment we have a single flat directory so this doesn't matter.

@MikaelSmith
Copy link
Contributor

MikaelSmith commented Jan 16, 2018

That's strange, what does your include directive look like?

I think there are some pretty strict limitations on it right now, but I've definitely used it for something like include file("/absolute/path") and include classpath("local/file").

Actually, I take that back... not sure I've used those examples with this hocon parser.

@luben
Copy link
Contributor

luben commented Jan 16, 2018

I think you are hitting #94

@luben
Copy link
Contributor

luben commented Jan 17, 2018

BTW, as I see some people commenting, is this project maintained? I sent a PR for fixing another bug with included files (#95) without any reaction for more than 3 months. @dvhwgumby , sorry for the noise,

@dvhwgumby
Copy link
Author

dvhwgumby commented Jan 17, 2018 via email

@dvhwgumby
Copy link
Author

dvhwgumby commented Jan 24, 2018

FWIW, the "spec" for HOCON ([https://github.com/lightbend/config/blob/master/HOCON.md#includes]) considers the syntax our team used to be legit.

@MikaelSmith
Copy link
Contributor

MikaelSmith commented Jan 24, 2018

Understood. This is currently an incomplete implementation of the spec. It would be nice to improve it, but I'm not personally spending a ton of time on it.

I'm surprised the lightbend parser rejected include file("foo"), since they seem to claim to support it in https://github.com/lightbend/config#features-of-hocon.

@SeaTalk
Copy link
Contributor

SeaTalk commented Jan 16, 2019

I ran into a similar situation.
In my case, I have a.conf and b.conf both in directory "ProjectDir/conf/".
a.conf is like

{ include "b.conf" ...}

when I run code in directory "ProjectDir/bin/", I always get an error:
Something went wrong when parsing hocon file. Exception message:reader() should not be called on resources

I wonder how I can fix that.

@MikaelSmith
Copy link
Contributor

I can give some suggestions of where to look to start a fix. Our code mirrors the lightbend/config implementation fairly closely, so you can use that to compare where we might be missing some implementation.

The parser is in src/config_document_parser.cc. parse_context::parse_include is the first place I'd look, which at least accepts include "foo". It's possible we're setting that up with the wrong type, but I suspect the actual problem is later. It's possible parse_context::parse_include in src/config_parser.cc is a problem.

If b.conf is empty, do you get an error? Possible the parser for the included file is not setup correctly.

@SeaTalk
Copy link
Contributor

SeaTalk commented Jan 18, 2019

In my case, I fix it by changing some code. And my change exists here . For now, it works fine for me. I want you guys review my code and find out where bugs may lay.
Thanks a lot ~

@MikaelSmith
Copy link
Contributor

Thanks for providing that! Not sure when someone might get to looking at it. If anyone's interested in turning that into a PR, I can try to help review it.

@MikaelSmith
Copy link
Contributor

I believe this is fixed by #115. Please re-open the issue if I'm mistaken.

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

4 participants