rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

Update Legacy Runfiles

Open aryeh-looker opened this issue 3 years ago • 3 comments

Repro:

  1. Apply this diff:
diff --git a/.bazelrc b/.bazelrc
index 6858b64..d7db834 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -2,3 +2,4 @@ build --strategy=KotlinCompile=worker
 build --test_output=all
 build --verbose_failures
 
+build --nolegacy_external_runfiles
  1. bazel run //src/test/data/jvm/basic:test_module_name_bin

Observed behavior:

Target fails to run:

 % bazel run //src/test/data/jvm/basic:test_module_name_bin
DEBUG: /usr/local/google/home/aryehh/.cache/bazel/_bazel_aryehh/8452aec00c6d558f60825d3f208d7152/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14: 
Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file.
DEBUG: /usr/local/google/home/aryehh/.cache/bazel/_bazel_aryehh/8452aec00c6d558f60825d3f208d7152/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:125:14: buildkite_config not using checked in configs; Bazel version 5.2.0 was picked/selected but no checked in config was found in map {"0.20.0": ["8.0.0"], "0.21.0": ["8.0.0"], "0.22.0": ["8.0.0", "9.0.0"], "0.23.0": ["8.0.0", "9.0.0"], "0.23.1": ["8.0.0", "9.0.0"], "0.23.2": ["9.0.0"], "0.24.0": ["9.0.0"], "0.24.1": ["9.0.0"], "0.25.0": ["9.0.0"], "0.25.1": ["9.0.0"], "0.25.2": ["9.0.0"], "0.26.0": ["9.0.0"], "0.26.1": ["9.0.0"], "0.27.0": ["9.0.0"], "0.27.1": ["9.0.0"], "0.28.0": ["9.0.0"], "0.28.1": ["9.0.0"], "0.29.0": ["9.0.0"], "0.29.1": ["9.0.0", "10.0.0"], "1.0.0": ["9.0.0", "10.0.0"], "1.0.1": ["10.0.0"], "1.1.0": ["10.0.0"], "1.2.0": ["10.0.0"], "1.2.1": ["10.0.0"], "2.0.0": ["10.0.0"], "2.1.0": ["10.0.0"], "2.1.1": ["10.0.0", "11.0.0"], "2.2.0": ["11.0.0"], "3.0.0": ["11.0.0"], "3.1.0": ["11.0.0"], "3.2.0": ["11.0.0"], "3.3.0": ["11.0.0"], "3.3.1": ["11.0.0"], "3.4.1": ["11.0.0"], "3.5.0": ["11.0.0"], "3.5.1": ["11.0.0"], "3.6.0": ["11.0.0"], "3.7.0": ["11.0.0"], "3.7.1": ["11.0.0"], "3.7.2": ["11.0.0"], "4.0.0": ["11.0.0"]}
DEBUG: /usr/local/google/home/aryehh/Development/rules_kotlin/kotlin/internal/jvm/impl.bzl:68:10: !!!
DEBUG: /usr/local/google/home/aryehh/Development/rules_kotlin/kotlin/internal/jvm/impl.bzl:69:10: external/local_jdk/bin/java
INFO: Analyzed target //src/test/data/jvm/basic:test_module_name_bin (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src/test/data/jvm/basic:test_module_name_bin up-to-date:
  bazel-bin/src/test/data/jvm/basic/test_module_name_bin.jar
  bazel-bin/src/test/data/jvm/basic/test_module_name_bin.jdeps
INFO: Elapsed time: 0.313s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
/usr/local/google/home/aryehh/.cache/bazel/_bazel_aryehh/8452aec00c6d558f60825d3f208d7152/execroot/dev_io_bazel_rules_kotlin/bazel-out/k8-fastbuild/bin/src/test/data/jvm/basic/test_module_name_bin: line 378: /usr/local/google/home/aryehh/.cache/bazel/_bazel_aryehh/8452aec00c6d558f60825d3f208d7152/execroot/dev_io_bazel_rules_kotlin/bazel-out/k8-fastbuild/bin/src/test/data/jvm/basic/test_module_name_bin.runfiles/dev_io_bazel_rules_kotlin/external/local_jdk/bin/java: No such file or directory

Expected behavior

Target runs successfully

aryeh-looker avatar Jun 18 '22 01:06 aryeh-looker

It looks like in https://github.com/bazelbuild/rules_kotlin/blob/7dcb7f94f3f367110d75a3ea4464ae4e4cbbf8f0/kotlin/internal/jvm/impl.bzl#L73 you need to use java_executable_runfiles_path instead of java_executable_exec_path. See the fix in rules_scala: https://github.com/bazelbuild/rules_scala/commit/e14f2528689efd04e54a332d2f27936eac45e2cb

hades avatar Jun 19 '24 07:06 hades

The workaround is to use kt_jvm_library+java_binary instead of kt_jvm_binary.

hades avatar Jun 19 '24 07:06 hades

I believe this was just fixed - see https://github.com/bazelbuild/rules_kotlin/pull/1242

drmercer-lucid avatar Dec 12 '24 00:12 drmercer-lucid