Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaTestRunner missing dependency warning on MacOS 11 #299

Closed
tshaynik opened this issue Dec 22, 2022 · 2 comments · Fixed by #453
Closed

JavaTestRunner missing dependency warning on MacOS 11 #299

tshaynik opened this issue Dec 22, 2022 · 2 comments · Fixed by #453
Assignees
Labels
P3 minor: not priorized type: bug

Comments

@tshaynik
Copy link
Contributor

Describe the bug
In #273 there are a bunch of changes to the Java toolchain to support using rules_nixpkgs with Bazel 6.
This fixes the main issues, but there is a failure in CI on MacOS while running the Java tests, with an error about needing to explicitly declare a dependency on @bazel_tools//tools/jdk:TestRunner, with error message recommending running buildozer 'add deps @bazel_tools//tools/jdk:TestRunner' //tests:java-test. Explicitly adding the dependency does not solve the problem and results in the same issue.
The temporary workaround for now is to setting the flag --experimental_strict_java_deps=warn, but we would like to remove this flag and have the Java tests work.

To Reproduce
In flake.nix, use nixpkgs version 22.11, and switch bazel_5 to bazel_6 in the build inputs.
In .bazelrc, remove the line build --experimental_strict_java_deps=warn.
Run the Java toolchain tests on MacOS 11:

cd toolchains/java
bazel test '//...'

Expected behavior
We should be able to remove the flag --experimental_strict_java_deps=warn, run the Java toolchain tests, and not have any failures

Environment

  • OS name + version: MacOS 11 (in CI)
  • Version of the code: f3d68f3

Additional context
My guess is that this is related to how Bazel 6 is packaged in nixpkgs, where there are some particular patches to the the Java toolchain.

@avdv
Copy link
Member

avdv commented Dec 23, 2022

Related issue: bazelbuild/bazel#16109

According to that issue, the strict java deps checking depends on a bugfix in Java 11. Which might not have landed in the zulu JRE we are getting from nixpkgs.

From the build logs here it is:

/nix/store/rfp2c390f2askg2id424a4rh9lpxqr8h-zulu11.48.21-ca-jdk-11.0.11

The issue mentions openjdk full version "11.0.12+7-LTS" (which does not work) vs. openjdk full version "11.0.15+10-LTS" (which is OK).

@avdv
Copy link
Member

avdv commented Dec 23, 2022

Confirming. Using an official Bazel binary on MacOS (via bazelisk) also fails, so it is not a Bazel packaging issue.

The runner on Github uses Eclipse Temurin 11.0.17+8 by default.

Using Eclipse Temurin 11.0.16 from nixpkgs also works fine. Changes to reproduce:

diff --git a/core/.bazelrc b/core/.bazelrc
index 1f1bbc4..c238ef0 100644
--- a/core/.bazelrc
+++ b/core/.bazelrc
@@ -7,9 +7,9 @@ build --crosstool_top=@nixpkgs_config_cc//:toolchain
 # recommended for `nixpkgs_cc_configure_hermetic`.
 # build --incompatible_enable_cc_toolchain_resolution
 
-build --java_runtime_version=nixpkgs_java_11
+build --java_runtime_version=nixpkgs_temurin
 build --java_language_version=11
-build --tool_java_runtime_version=nixpkgs_java_11
+build --tool_java_runtime_version=nixpkgs_temurin
 build --tool_java_language_version=11
 
 # User Configuration
diff --git a/toolchains/java/WORKSPACE b/toolchains/java/WORKSPACE
index b1a7cbc..ae62076 100644
--- a/toolchains/java/WORKSPACE
+++ b/toolchains/java/WORKSPACE
@@ -14,6 +14,16 @@ load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_depende
 
 rules_nixpkgs_dependencies(toolchains = ['cc', 'posix'])
 
+load("//:java.bzl", "nixpkgs_java_configure")
+
+nixpkgs_java_configure(
+        attribute_path = "temurin-bin-11.home",
+        repository = "@nixpkgs",
+        toolchain = True,
+        toolchain_name = "nixpkgs_temurin",
+        toolchain_version = "11",
+)
+
 load("@rules_nixpkgs_core//docs:dependencies_1.bzl", "docs_dependencies_1")
 
 docs_dependencies_1()

BTW, this is not only a problem when switching to Bazel 6, it also fails with Bazel 5 as can be observed by the warning here for the changes in PR #273 .

tshaynik added a commit that referenced this issue Dec 23, 2022
This causes a warning instead of an error for strict Java dependencies
on MacOS. This is a temporary workaround for #299
and should be removed as soon as that issue is resolved.
@benradf benradf added the P3 minor: not priorized label Aug 3, 2023
avdv added a commit that referenced this issue Nov 24, 2023
The JRE we get from nixpkgs is now recent enough and strict deps checking works properly.

Fixes #299
@avdv avdv self-assigned this Nov 24, 2023
@mergify mergify bot closed this as completed in #453 Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 minor: not priorized type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants