Skip to content

Error in java_home fails to print the error message #14631

@pnicolas-vmware

Description

@pnicolas-vmware

Description of the problem / feature request:

If the jdk specified by java_home is not present, the error message itself fails with

ERROR: An error occurred during the fetch of repository 'toolchain_oracle_jdk8_lin64':
   Traceback (most recent call last):
        File "[...]/external/bazel_tools/tools/jdk/local_java_repository.bzl", line 28, column 32, in _local_java_repository_impl
                "does not exist." % (java_home, str(java_home_path)))
Error: not all arguments converted during string formatting

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

specify a non-existent jdk, run the build

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

release 4.1.0-vmware

Any other information, logs, or outputs that you want to share?

Patch to fix the issue

diff --git a/tools/jdk/local_java_repository.bzl b/tools/jdk/local_java_repository.bzl
index 4c0a433f8f..68402a7cce 100644
--- a/tools/jdk/local_java_repository.bzl
+++ b/tools/jdk/local_java_repository.bzl
@@ -123,8 +123,8 @@ def _local_java_repository_impl(repository_ctx):
     java_home = repository_ctx.attr.java_home
     java_home_path = repository_ctx.path(java_home)
     if not java_home_path.exists:
-        fail('The path indicated by the "java_home" attribute "%s" (absolute: "%s") ' +
-             "does not exist." % (java_home, str(java_home_path)))
+        fail(('The path indicated by the "java_home" attribute "%s" (absolute: "%s") ' +
+             "does not exist.") % (java_home, str(java_home_path)))

     repository_ctx.file(
         "WORKSPACE",

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)team-Rules-JavaIssues for Java rulestype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions