rules_kotlin
rules_kotlin copied to clipboard
fix running kotlin targets (at least under bzlmod?)
I was just integrating rules_kotlin into an existing bazel project and run into some issues getting a simple kotlin app up and running. I was seeing the error
...<app>.runfiles/_main/external/rules_java~~toolchains~remotejdk21_macos_aarch64/bin/java: No such file or directory
I explored a little and saw that these two fields in the java toolchain differed and explained the problem (since exec is what's being used, but runfiles is what points to the actual file.)
java_executable_exec_path = external/rules_java~~toolchains~remotejdk21_macos_aarch64/bin/java
java_executable_runfiles_path = ../rules_java~~toolchains~remotejdk21_macos_aarch64/bin/java
Looking at the docs for these two fields (https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaRuntimeInfoApi.java#L60 ) it looks to me like exec is for use while running java as part of the action, whereas runfiles is for use when using bazel run (but this is all a bit new to me so I might be wrong / perhaps there's some nuance -- e.g. I can see in (what looks to me like) the core java stuff, there's all sorts of complex stuff going on when they set javabin . . . -- https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary.bzl#L203 )
env details
- macos
- bazel version: 7.1.0
- rules_kotlin version: 1.9.1
[edit] forgot to mention, that I'm using this as a patch and bazel run <kotlin app target> is working fine now
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.