<@UJV6CBCKW> FromResource() will load from the cla...
# http4k
d
@Razi Kheir FromResource() will load from the classpath and not from a file on disk
👍 1
r
I see, so resource comes first but file system is just before last? Why is it not detecting my filesystem override unless its the first in line?
d
There shouldn't be a special order apart from the chain that you specify.
r
I mean if I put the filesystem environment as the first override everything works prefectly the lenses read the variables etc. If I put it under jvm flags, suddenly it throws lens exception
I would assume that if it doesn’t find any jvm flags for example it would then search in the second one instead of throwing exception no?
d
Yes - that the expected behaviour.
Can you post a simple.code version that we can run?
r
Ill do that later today 🙂 thanks
👍 1
I solved it by making all the lenses use EnvironmentKey.xxx().optional instead of .required. I will post an example anyway later today
d
Here's my experiment, which works ok:
Copy code
fun main() {
    /**
     * Given: foo.propertie
     * 
     * foo=bar
     */
    val key = EnvironmentKey.required("foo")

    val file = Environment.from(File("path/foo.properties"))

    val comp = Environment.from("BAR" to "foo") overrides file

    println(key(comp))
}