Open Naillik1 opened 3 years ago
I don't think the config library itself does textual concatenation- it may be the problem here is in a fat jar build plugin that concats files textually? maybe it could add a newline?
So what you're seeing is the reference.conf files get concatenated without inserting newlines.
This is not something typesafe-config can help: the files are concatenated by your build tool - in this case, by the sbt-assembly plugin.
I remember seeing the behavior you describe (and making sure my reference.conf files have a newline at the end). However, looking at the sources for the 'concat' merge strategy of sbt-assembly, it seems it should be inserting a newline if there is none: https://github.com/sbt/sbt-assembly/blob/v0.15.0/src/main/scala/sbtassembly/MergeStrategy.scala#L66 . That code seems to have been there for quite a while, too.
If you expect your library to be used in projects that are not using sbt, it might be smart to just make sure the newline is there - even if you fix sbt-assembly, other build tools/plugins might be harder to configure to insert those newlines.
If it's indeed a bug, I'm happy to contribute a fix (though I'd appreciate any pointers as to where to start).
This looks like it might be a bug in sbt-assembly, so I'd start looking closer there.
@raboof Ah, that looks to be it -- I've been using mill, and taking a closer look concatenation during mill's assembly task appears to be the issue. Thanks for pointing me in the right direction!
Hi! Came across this problem with config file concatenation, and it seems like a bug -- if it's the intended behaviour, I'd love to know where I went wrong.
Problem
I have two Scala projects:
app
&lib
, wherelib
is included as a dependency ofapp
. Bothapp
&lib
depend on typesafe config1.4.0
via PureConfig 0.13.0. Each has areference.conf
.Recently, an end-of-file newline was removed from
lib/../reference.conf
, causing various parsing errors upon attempting to load configs inapp
. Which particular error is thrown depends on the contents of the first line ofapp/.../reference.conf
.Examples
Base
The following examples are the results of varying either
lib/.../reference.conf
orapp/.../reference.conf
, then re-building and runningapp
(sbt assembly; java -jar /out/app/assembly/dest/out.jar
)1. Primitive on first line of app/.../reference.conf yields
ConfigException
:Parse
2. Object on first line of app/.../reference.conf yields
ConfigException
:WrongType
lib
code and to recognize thatsnag
was a config value found inlib
. Without both, I'd be no closer to knowing what's going on.3. Inserting a newline at first line of app/.../reference.conf properly loads config
4. Inserting a newline at lib/.../reference.conf end-of-file properly loads config
I'd expect config file concatenation to insert a break between files to guard against this; is there a reason why concatenating config files doesn't do this? Or is there some other mechanism I'm missing that I should be doing?
If it's indeed a bug, I'm happy to contribute a fix (though I'd appreciate any pointers as to where to start).