rules_kotlin
rules_kotlin copied to clipboard
Kotlin rules don't work with `bazel --nolegacy_external_runfiles`
There are performance benefits to using --nolegacy_external_runfiles (code here) as a Bazel build option, with some additional context here. As @alexeagle tells me, it allows for an optimization in runfiles layout.
As things are, this setting appears to be incompatible with rules_kotlin. When I try to build a kt_jvm_library with bazel build --nolegacy_external_runfiles, I get an error like the following:
Click to expand logs
$ bazel run --nolegacy_external_runfiles src/main/kotlin/experimental/users/sabraham:thing
INFO: Analyzed target //src/main/kotlin/experimental/users/sabraham:thing (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/sean/dev/central-ult/src/main/kotlin/experimental/users/sabraham/BUILD.bazel:15:14: KotlinCompile @//src/main/kotlin/experimental/users/sabraham:thing { kt: 1, java: 0, srcjars: 0 } for darwin_arm64 failed: Worker process did not return a WorkResponse:
---8<---8<--- Start of log, file at /private/var/tmp/_bazel_sean/3e0bb96a7b651dc41ed28d370dc8ba44/bazel-workers/worker-4-KotlinCompile.log ---8<---8<---
Exception in thread "main" java.lang.ExceptionInInitializerError
at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:33)
at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:29)
at io.bazel.worker.Worker$Companion.from(Worker.kt:31)
at io.bazel.kotlin.builder.cmd.Build.main(Build.kt:29)
Caused by: java.lang.IllegalStateException: file did not exist: /private/var/tmp/_bazel_sean/3e0bb96a7b651dc41ed28d370dc8ba44/execroot/videoamp/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/io_bazel_rules_kotlin/src/main/kotlin/build.runfiles/../com_github_jetbrains_kotlin/lib/jvm-abi-gen.jar
at io.bazel.kotlin.builder.utils.IOUtils.verified(IOUtils.kt:86)
at io.bazel.kotlin.builder.utils.IOUtils.resolveVerified(IOUtils.kt:80)
at io.bazel.kotlin.builder.utils.BazelRunFiles.resolveVerified(BazelRunFiles.kt:94)
at io.bazel.kotlin.builder.toolchain.KotlinToolchain.<clinit>(KotlinToolchain.kt:57)
... 4 more
---8<---8<--- End of log ---8<---8<---
Alex pointed me to a related fix he made in rules_jvm_external, which made those rules compatible with --nolegacy_external_runfiles. rules_kotlin would ideally work with that option too.
Alex DMed the following to me: "Yeah it's going to be a tiny change like s#external/#../# but the hard part is where that line is 🙂"