-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel throws exception if no local JDK is installed #6993
Comments
I also sometimes see a different, non-genrule error when building with v0.21:
|
Works here on macOS as expected, on bazel 0.21:
|
/cc @cushon |
I put together a quick test case to print out $JAVABASE and the available sandbox files. Here's what I get with v0.21, v0.20, and v0.18:
|
Total newbie, sorry if this is not related, but I get the " warning: could not find a JDK 8 bootclasspath in external/local_jdk, falling back to --release" when running the examples at https://docs.bazel.build/versions/master/tutorial/java.html with anything later than 0.18.1. I'm on Void Linux and installed bazel with the .sh installer, JDK openjdk-1.8.0_202 |
This is a harmless warning and is a known issue that was fixed on 0.21. |
John, we tried to repro the build failure on a Mac with JDK10 and on the Macs on buildkite run JDK8 (see https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/729#a8c276a7-b88e-4341-936a-e970e3ecfa4e) and didn't succeed. So I'm wondering what could be different on your machine. |
Hmm, on my work laptop the
|
I assume you can also build Bazel there? Can we close the issue then until you have a more specific repro? |
Can you leave this open? I'd like to further debug why my personal laptop isn't getting a |
Sure, I've assigned it to you. |
current reproduction: # BUILD
genrule(
name = "gen_java",
srcs = ["@bazel_tools//tools/jdk:current_java_runtime"],
outs = ["dummy"],
cmd = "find .",
)
|
Bazel is resolving If I try to compile a trivial
Running Bazel with either I'm pretty confused about why, exactly, Bazel is defaulting |
Although it's a bug that the build fails in that way, it is expected that you have to specify a javabase if you don't have a local JDK installed. Also using the embedded JDK for that is no longer possible starting from the next release since it will no longer be exposed (and with 0.23 minimized). @lberki may have an idea what's wrong with the local_jdk detection since he fixed some expectations around it IIRC. |
The implementation of the
and if |
Related: "improve diagnostics for incorrect |
I feel like failure to detect a mandatory toolchain should result in a specific error from Bazel, similar to how it complains loudly if it can't find a C++ compiler when building a C++ binary. Defaulting the JDK path to the workspace directory is deeply unintuitive. |
/cc @katre |
I agree that this needs a better error. We're currently changing how Java rules handle the toolchain and runtime dependencies, this will affect a genrule that uses |
Installing the default-jdk on Debian 9 fixed the problem for me. However, the gen_java target/test from an earlier comment still fails. |
See bazelbuild/bazel#6993 Change-Id: If81af47c23f8228b94db41e5b0edbcd60f45718c GitOrigin-RevId: e219a10
cc @Wyverald who ran into the same problem recently |
It looks like this was caused by javabase refactorings in these versions, with two distinct breakages occurring in 0.18 -> 0.19 and 0.20 -> 0.21. Representative build logs from a build with Bazel 0.21:
The genrule comes from a macro:
Editing that genrule to print out what files it sees indicates that
$(JAVABASE)
has become decoupled from$(locations @bazel_tools//tools/jdk:current_java_runtime)
.$(JAVABASE)
=external/local_jdk
./external/local_jdk/include/jni.h
$(JAVABASE)
=external/local_jdk
./external/embedded_jdk/include/jni.h
$(JAVABASE)
=external/local_jdk
./external/embedded_jdk/include/jni.h
$(JAVABASE)
=external/local_jdk
./external/remotejdk_macos/include/jni.h
The text was updated successfully, but these errors were encountered: