-
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
Unable to build Java example using homebrew #15452
Comments
Bazel uses its own (remote) JDK to compile and its own (sever) JDK to run, but it inspects local JDK and uses its boot classpaths, so that the produced code/jars can execute locally. And this is where the error is happening. Here is where JDK discovery is implemented for mac: Can you double check JAVA_HOME is set correcty? |
@comius I can confirm my
|
The error was happening before when Java was installed with homebrew and not found. See #6993 I wonder if Can you give me more debugging information? I'm interested in platformclasspath invocation, which is failing. Running your build with |
@comius Here are the outputs: Command:
Command:
|
JDK (not Bazel) checks presence of Based on your output:
they are not there. Please try with another JDK installation. Others have reported that there are issues with homebrew installation |
The error reporting could be improved by catching |
I faced the same issue (using Mac M1) |
When JavacTools#create throws IllegalArgumentException, the likely cause is that the configured Java runtime is not a JDK or missing files, as is known to be the case with Homebrew installations. Rather than fail with a cryptic stack trace that only mentions `external/local_jdk`, print a descriptive error with the resolved path of the configured runtime's home directory. Fixes bazelbuild#15452 Closes bazelbuild#16346. PiperOrigin-RevId: 477708308 Change-Id: Ibe28a9d5debe633d1dadc0d4638da25fd324c5a6
Description of the bug:
I get errors when trying to build the example project without modification at https://bazel.build/tutorials/java. I've investigated it for an hour but am still completely baffled on why I keep getting errors.
The error is the same when using the x64 version of Bazel running under Rosetta 2.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Use the
java-tutorial
example athttps://github.com/bazelbuild/examples
.Run
bazel build //:ProjectRunner
.Which operating system are you running Bazel on?
macOS Monterey 12.3.1 Apple M1
What is the output of
bazel info release
?release 5.1.1
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.n/a
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Have you found anything relevant by searching the web?
No.
Any other information, logs, or outputs that you want to share?
JDK version: my original one was openjdk provided by Homebrew which is 18.0.1. I switched to
openjdk@11
and set the correspondingJAVA_HOME
variable but still got the same error. But since Bazel builds the project using its own JDK, this should not be a factor, right?bazel info
:The text was updated successfully, but these errors were encountered: