我在最新的Debian测试中使用了以下配置:
$ 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
我已经安装了openjdk 11(目前是11.0.11),并且update-alternatives
通过/usr/bin/java
指向它。环境变量JAVA_HOME
是unset。
在此配置中,以下命令将失败:
$ 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)
其他生成命令成功。这是一个VM设置,在具有如上所述相同配置的其他VM示例上,此命令成功。
我很感激你的提示。像bazel clean
这样简单的东西在a similar question中没有帮助,我甚至完全删除了构建缓存,但无济于事。顺便说一句,我的构建与android无关。
3条答案
按热度按时间mwngjboj1#
我有同样的错误,但我解决了它与正确安装的jdk。检查您的版本的bazel没有标记这个警告:
如果出现此警告,则意味着我们的jdk有问题,请使用以下命令验证是否安装了javac命令:
如果没有安装,请查找适合您的平台的安装,在我的例子中,使用以下命令:
最后,使用以下命令验证安装目录:
确保JAVA_HOME配置正确。
ppcbkaq52#
今天,我进行了很久以来的第一次重新测试,问题似乎没有了。VM正在运行
bullseye
。Bazel版本:
Java版本:
可能是海森堡...
new9mtju3#
这是一个令人困惑的错误消息-它说它找不到
bin/java
,但我的系统上确实有java
可用。问题是我有JRE(Java运行时环境),它可以让你用
java
命令运行Java程序,但我没有JDK(Java开发环境),它可以让你用javac
命令 * 编译 * Java代码。我使用的是RHEL 8,所以我是这样安装的: