I am using the following configuration on an up-to-date Debian Testing:
$ bazel version
Bazelisk version: v1.10.1
Starting local Bazel server and connecting to it...
Build label: 4.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jan 21 07:33:24 2021 (1611214404)
Build timestamp: 1611214404
Build timestamp as int: 1611214404
I have openjdk 11 (currently 11.0.11) installed and update-alternatives points to it via /usr/bin/java. Environment variable JAVA_HOME is unset.
In this configuration the following command fails:
$ bazel coverage --config=linux_x86 -c dbg --instrumentation_filter="//implementation:atos_utest" //implementation/src/utest:all 2>&1 | tee /tmp/buildlog.txt
2021/07/30 16:40:49 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-linux-x86_64...
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
currently loading: implementation/src/utest
Analyzing: 27 targets (1 packages loaded)
Analyzing: 27 targets (1 packages loaded, 0 targets configured)
Analyzing: 27 targets (18 packages loaded, 73 targets configured)
Analyzing: 27 targets (27 packages loaded, 144 targets configured)
ERROR: /home/atoml/.cache/bazel/_bazel_atoml/ababbc8a7f78bac9d28b91a651da5105/external/local_jdk/BUILD.bazel:3:10: in fail_rule rule @local_jdk//:jdk:
Traceback (most recent call last):
File "/home/atoml/.cache/bazel/_bazel_atoml/ababbc8a7f78bac9d28b91a651da5105/external/bazel_tools/tools/jdk/fail_rule.bzl", line 19, column 13, in _fail_rule_impl
fail("%s %s" % (ctx.attr.header, ctx.attr.message))
Error in fail: Auto-Configuration Error: Cannot find Java binary bin/java in /home/atoml/.cache/bazel/_bazel_atoml/install/1a4a2fac02d50c77031d44c0d91b8920/embedded_tools/tools/jdk/nosystemjdk; either correct your JAVA_HOME, PATH or specify embedded Java (e.g. --javabase=@bazel_tools//tools/jdk:remote_jdk11)
ERROR: Analysis of target '//implementation/src/utest:uut_compdb' failed; build aborted: Analysis of target '@local_jdk//:jdk' failed
INFO: Elapsed time: 7.681s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (29 packages loaded, 367 targets configured)
ERROR: Couldn't start the build. Unable to run tests
FAILED: Build did NOT complete successfully (29 packages loaded, 367 targets configured)
Other build commands succeed. This is a VM setup, on other VM instances with the same configuration as described above, this command succeeds.
I'd be grateful for hints. Simple things like bazel clean as in a similar question do not help, I have even removed the build cache completely, but to no avail. BTW. my build has nothing to do with android.
I had the same error but I resolved it with the correct installation of the jdk. Check that your version of bazel does not mark this Warning:
bazel version
Bazelisk version: v1.11.0
**WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.**
Build label: 4.2.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Aug 30 15:17:47 2021 (1630336667)
Build timestamp: 1630336667
Build timestamp as int: 1630336667
If this warning appears, it means that we have a problem with the jdk, validate that you have the javac command installed with the following command:
javac -version
If it is not installed, look for the installation for your platform, in my case it is with the following command:
sudo apt install default-jdk
Finally verify the installation directory with the following command:
sudo update-alternatives --config javac
Make sure you have the JAVA_HOME configured correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With