[Build Failure] Bazel fails to find toolchains for java on FreeBSD 14-CURRENT amd64 from git checkout at HEAD While resolving toolchains for target @rules_jvm_external//private/tools/java/rules/jvm/external/jar:AddJarManifestEntry: No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type.
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
Attempting to build bazel from source (without bootstrapping) using a previously bootstrapped version of bazel.
```
Tue Jan 10 09:06 AM yesudeep at mongolia running bash5.2 on FreeBSD 14.0-CURRENT amd64
in ~/src/bazel master
>> bazel build //src:bazel-dev
Starting local Bazel server and connecting to it...
INFO: Repository zstd-jni instantiated at:
/usr/home/yesudeep/src/bazel/WORKSPACE:217:18: in
/usr/home/yesudeep/src/bazel/distdir.bzl:94:17: in dist_http_archive
Repository rule http_archive defined at:
/usr/home/yesudeep/src/bazel/tools/build_defs/repo/http.bzl:372:31: in
INFO: Repository remote_java_tools instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:363:6: in
/usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule http_archive defined at:
/usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in
INFO: repository @remote_java_tools' used the following cache hits instead of downloading the corresponding file.
* Hash '5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d' for https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip
If the definition of 'repository @remote_java_tools' was updated, verify that the hashes were also updated.
INFO: Repository openjdk_linux_vanilla instantiated at:
/usr/home/yesudeep/src/bazel/WORKSPACE:148:15: in
/usr/home/yesudeep/src/bazel/distdir.bzl:112:14: in dist_http_file
Repository rule http_file defined at:
/usr/home/yesudeep/src/bazel/tools/build_defs/repo/http.bzl:466:28: in
ERROR: /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/rules_jvm_external/private/tools/java/rules/jvm/external/jar/BUILD:3:12: While resolving toolchains for target @rules_jvm_external//private/tools/java/rules/jvm/external/jar:AddJarManifestEntry: No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@bazel_tools//tools/jdk:runtime_toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '//src:bazel-dev' failed; build aborted:
INFO: Elapsed time: 11.199s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (322 packages loaded, 4809 targets configured)
Fetching /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/remote_java_tools; Extracting java_tools-v11.9.zip
Fetching https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.38.21-ca-jdk17.0.5-linux_x64.tar.gz; 26.6 MiB (27,859,757B)
Fetching /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/zstd-jni; Extracting v1.5.2-3.zip
```
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
1. git clone https://github.com/bazelbuild/bazel
2. bazel build //src:bazel-dev
### Which operating system are you running Bazel on?
FreeBSD 14-CURRENT amd64
### What is the output of `bazel info release`?
bazel 6.0.0-2023-01-01 (@e724a5a)
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
1. I used OpenJDK 11.
2. Download https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-dist.zip
3. Run unzip bazel-6.0.0-dist.zip
4. Run env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh
The release version doesn't build with OpenJDK 17 and 18. Bug filed here: https://github.com/bazelbuild/bazel/issues/17103
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
```text
>> git remote get-url origin; git rev-parse master; git rev-parse HEAD
https://github.com/bazelbuild/bazel
36a640be338b86d3cb43a9ed3e7b38a5754fb2af
36a640be338b86d3cb43a9ed3e7b38a5754fb2af
```
### Have you found anything relevant by searching the web?
- [ ] Build failure with OpenJDK 17 and 18: https://github.com/bazelbuild/bazel/issues/17103
- [ ] rules_java doesn't build java code because it can't find a toolchain either: https://github.com/bazelbuild/rules_java/issues/84
- [ ] Read the documentation and determined that I'd have to use the local JDK as the toolchain on FreeBSD.https://bazel.build/docs/bazel-and-java
### Any other information, logs, or outputs that you want to share?
Adding the following to ~.bazelrc~ addresses the issue of unresolved toolchains.
```
common --enable_platform_specific_config
# FreeBSD requires a local JDK configuration because rules_java/rules_jvm_external don't have a remote JDK for FreeBSD.
# See: https://bazel.build/docs/bazel-and-java
build:freebsd --extra_toolchains=@local_jdk//:all
build:freebsd --java_runtime_version=local_jdk
build:freebsd --tool_java_runtime_version=local_jdk
```
Contributor guide
Research direction
Start with the reported `bazel build //src:bazel-dev` reproduction on FreeBSD and inspect the `.bazelrc` platform-specific settings alongside the toolchain failure in the external `rules_jvm_external` BUILD file. Use the referenced `--toolchain_resolution_debug` option to trace `@bazel_tools//tools/jdk:runtime_toolchain_type`; done means the source build resolves a Java runtime toolchain without the manual local-JDK workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100