no such target '@@+toolchains+local_jdk//:runtime_toolchain_definition' on Windows when JAVA_HOME is set to mapped drive

Open
#339 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
build-system

Research direction

Reproduce with JAVA_HOME set to the mapped drive path t:\jdk\jdk21, then compare the failing external +toolchains+local_jdk/BUILD.bazel at line 78 with the successful local-drive case. Inspect toolchains/BUILD at line 285 and the empty glob result; done means Bazel build succeeds with the mapped-drive JDK and the runtime toolchain is registered.

Written by the indexing model from the issue text.

Description

P3 question

I set JAVA_HOME to a mapped network drive copy of JDK 21 on Windows.
This is with latest rules_java and all rules_java releases back to 8.5 (I stopped searching at that point)

set JAVA_HOME=t:\jdk\jdk21
Bazel build fails

D:\workdir\github\rules_java>bazel build //... --noincompatible_disallow_empty_glob
ERROR: Traceback (most recent call last):
        File "D:/udu/b/4skhmsqa/external/+toolchains+local_jdk/BUILD.bazel", line 78, column 66, in <toplevel>
                java = glob(["bin/java.exe", "bin/java"], allow_empty = True)[0],
Error: index out of range (index is 0, but sequence has 0 elements)
ERROR: D:/workdir/github/rules_java/toolchains/BUILD:285:14: While resolving toolchains for target //toolchains:platformclasspath (4e49fa3): invalid registered toolchain '@local_jdk//:runtime_toolchain_definition': no such target '@@+toolchains+local_jdk//:runtime_toolchain_definition': target 'runtime_toolchain_definition' not declared in package '' defined by D:/udu/b/4skhmsqa/external/+toolchains+local_jdk/BUILD.bazel
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of target '//toolchains:platformclasspath' failed; build aborted
INFO: Elapsed time: 1.601s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

set JAVA_HOME to a local copy

xcopy /E t:\jdk\jdk21 d:\jdk\jdk21
set JAVA_HOME=d:\jdk\jdk21

Bazel build succeeds
Dominant language
Starlark
Stars
103
Forks
102
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_java

All issues in bazelbuild/rules_java

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.