Fork me on GitHub
#graalvm
<
2022-02-23
>
nixin7202:02:46

Hi, I'm not sure if this is the right channel to ask this, but I'm having compilation issues with GraalVM native-image that seem to be specific to running the build in GitHub CI. The native image compiles fine as in it doesn't throw any errors, but the executable produced from it is throwing errors that don't occur when building locally. Here's the full output from the CI build: https://github.com/nixin72/shan/runs/5297774183?check_suite_focus=true Here's the error that it's throwing when trying to run the executable produced:

> ./shan-0.1.0-snapshot-linux
Here
Error: Exception in thread "main" java.io.IOException: No such file or directory
	at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_IOException_constructor_dfe3139624312c30e7f76f0e723ef6192050fcf4(JNIJavaCallWrappers.java:0)
	at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java)
	at java.io.File.createNewFile(File.java:1035)
	at shan.config$create_file.invokeStatic(config.clj:13)
	at shan.config$create_file.invoke(config.clj:10)
	at shan.config$setup_first_time_use.invokeStatic(config.clj:56)
	at shan.config$setup_first_time_use.invoke(config.clj:46)
	at shan.core$_main.invokeStatic(core.clj:53)
	at shan.core$_main.doInvoke(core.clj:52)
	at clojure.lang.RestFn.invoke(RestFn.java:397)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at shan.core.main(Unknown Source)
Error: Process completed with exit code 1.
The error is coming from this file https://github.com/nixin72/shan/blob/master/src/shan/config.clj#L56 when trying to create a file. I thought at first this might be an issue with trying to create the file in a docker environment for some reason? But I downloaded the build artifact and ran it locally and it produces the same error. Anyone know what might be the issue with this?

borkdude09:02:36

When compiling Clojure programs, top level defs must be delayed, or they will be executed at compile time.

nixin7215:02:01

Hmm... I understand how that could make something compiled in a CI environment not work when downloading the native image to local, but I don't see why that would break it running the image in the CI environment? I will remove the top-level defs though. What's the best way of handling this sort of thing instead of assigning them at top level?

borkdude15:02:11

wrapping them in a delay or function

nixin7221:02:05

Ahah! Thanks @U04V15CAJ! That solved one part of my problem! Was able to get everything else working from there. 47 tries and 3 evenings later and my CI pipeline finally produces working builds!

🎉 1