Skip to content

java not found for kt_jvm_binary targets executed from a rule #1332

@tharakadesilva

Description

@tharakadesilva

I have a kt_jvm_binary target defined as follows:

kt_jvm_binary(
    name = "DownloaderApplication",
    main_class = "myapp.DownloaderKt",
    visibility = ["//:__subpackages__"],
    runtime_deps = [":downloader"],
)

When I run this as bazel run //downloader:DownloaderApplication asd asd, things are working as expected.

However, when I try to run this from a rule, I run into:

ERROR: /Users/tharakadesilva/git_tree/tharakadesilva/rules_kotlin_1332/BUILD.bazel:3:14: Downloading data failed: (Exit 126): DownloaderApplication failed: error executing DownloadData command (from target //:download_data) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/downloader/DownloaderApplication --output bazel-out/darwin_arm64-fastbuild/bin/output.csv some args

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/downloader/DownloaderApplication: line 412: /private/var/tmp/_bazel_tharakadesilva/b372dc11837e8cf37fe5cff4ecc060ad/sandbox/darwin-sandbox/14/execroot/_main/../rules_java++toolchains+remotejdk11_macos_aarch64/bin/java: No such file or directory
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/downloader/DownloaderApplication: line 412: exec: /private/var/tmp/_bazel_tharakadesilva/b372dc11837e8cf37fe5cff4ecc060ad/sandbox/darwin-sandbox/14/execroot/_main/../rules_java++toolchains+remotejdk11_macos_aarch64/bin/java: cannot execute: No such file or directory
Target //:download_data failed to build

Steps to Reproduce

Full repro: https://github.com/tharakadesilva/rules_kotlin_1332/tree/main

Run: bazel build :download_data


Workaround

Seems to be related to: #1242

Using the workaround here (using java_binary) works.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions