com-lihaoyi / os-lib

OS-Lib is a simple, flexible, high-performance Scala interface to common OS filesystem and subprocess APIs
Other
690 stars 71 forks source link

os.pwd0 unexpected value when compiled with GraalVM and class init at build time. #318

Open mio-19 opened 1 week ago

mio-19 commented 1 week ago

I built my scala program with GraalVM and class init at build time. From the error message I find that os.pwd0 is defined as a val, which was probably calculated by GraalVM compiler at build time, which leads to unexpected behaviour.

lihaoyi commented 1 week ago

This seems like a problem with your graal confifg, not with os-lib. We can't change everything to lazy vals to satisfy graal

mio-19 commented 1 week ago

How about make it a def like https://github.com/com-lihaoyi/os-lib/pull/239?

lihaoyi commented 1 week ago

I'd like a deeper investigation before we make another change. Graal has to support cases like this. Static vals that require environmental data during initialization are not rare.

If not, I'd like a link to the upstream ticker and discussion in the graal issue tracker before we make any further changes in OS-Lib

mio-19 commented 5 days ago

One option is to provide native image configuration in META-INF, like what some popular java libraries did