Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remotely-built java_binarys can't run locally #10021

Closed
kevingessner opened this issue Oct 14, 2019 · 3 comments
Closed

remotely-built java_binarys can't run locally #10021

kevingessner opened this issue Oct 14, 2019 · 3 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-Java Issues for Java rules type: bug

Comments

@kevingessner
Copy link
Contributor

Description of the problem / feature request:

java_binary targets that are built with remote execution can't run locally, because the wrapper script has the wrong path to java.

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

Create a straightforward java_binary with some deps, e.g.

java_binary(
    name = "foo",
    main_class = "my.foo",
    runtime_deps = [
        "//my/foo",
        "//third_party/jvm/org/apache/logging/log4j:log4j_core",
    ],
)

Build it with the a remote execution config using rbe_autoconfig from Bazel toolchains 0.29.8 and the default build container (e.g. with Google RBE).

The binary builds fine with bazel --config=remote build //:foo. However, it fails when run with bazel --config=remote run //:foo:

/home/kgessner/.cache/bazel/_bazel_kgessner/[snip]/foo: line 359: /usr/lib/jvm/java-8-openjdk-amd64/bin/java: No such file or directory

The java_binary wrapper/launcher has the wrong java path: /usr/lib/jvm/java-8-openjdk-amd64/bin/java is the path to java in the build container, but not locally.

I can't find a combination of javabase/java_toolchain that makes the wrapper include my local JDK without breaking RBE. I can work around it with --java_launcher=@bazel_tools//tools/jdk:java but that results in a deprecation warning about local_jdk, so it's not a sustainable solution.

What operating system are you running Bazel on?

centos 7

What's the output of bazel info release?

release 0.29.1

Have you found anything relevant by searching the web?

I did ask on SO: https://stackoverflow.com/questions/58348645/remotely-built-java-binarys-cant-run-locally

I found this about the local_jdk deprecation warning but those solutions aren't compatible with --java_launcher: https://stackoverflow.com/questions/53066974/how-can-i-use-the-jar-tool-with-bazel-v0-19

@jin jin added team-Rules-Java Issues for Java rules untriaged labels Oct 14, 2019
@iirina iirina added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Oct 17, 2019
@evantorrie
Copy link

I too have this problem. It seems to pull the remote java toolchain's "java" path rather than using the local host.

@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 24, 2023
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-Java Issues for Java rules type: bug
Projects
None yet
Development

No branches or pull requests

5 participants