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

IntelliJ Fast Run / Debug does not automatically pick the correct path to java in the runfiles directory #6554

Open
JohnnyMorganz opened this issue Jul 5, 2024 · 0 comments
Labels
lang: java Java rules integration P3 We're not considering working on this, but happy to review a PR. (No assignee) product: IntelliJ IntelliJ plugin type: bug

Comments

@JohnnyMorganz
Copy link

Description of the bug:

I am trying to use the Fast Run feature of the intellij plugin for bazel. In our setup, we are using the default Java toolchains with a remote JDK toolchain, which is used for hermetic testing and compilation: https://bazel.build/docs/bazel-and-java#hermetic-testing

When trying to run a fast build, I get the following error

Error running 'Bazel test <class name>'
Cannot run program "../local_jdk/bin/java" (in directory "<runfiles directory>"): error=2, No such file or directory

In our setup, the java binary is present at ../remotejdk11_linux/bin/java.

Looking at the code, it seems the fast build set up is hardcoded to look for the local_jdk, rather than the jdk configured in our toolchain

private static final File STANDARD_JAVA_BINARY = new File("../local_jdk/bin/java");

I would expect the plugin to identify what is the toolchain setup, and pick the appropriate path to the java binary.

Which category does this issue belong to?

Intellij

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

Create a fresh bazel WORKSPACE with a simple java test target and add the following to your .bazelrc:

build--tool_java_runtime_version=remotejdk_11 --tool_java_language_version=11
build--java_runtime_version=remotejdk_11 --java_language_version=11

Open the project in IntelliJ and start a Bazel sync. Try to Fast Run your test class. It should fail with the above error message

Which Intellij IDE are you using? Please provide the specific version.

IntelliJ IDEA 2024.1 Build #JBC-241.14494.240

What programming languages and tools are you using? Please provide specific versions.

Java 11, Bazel 7.2.1

What Bazel plugin version are you using?

2024.06.18.0.1-api-version-241

Have you found anything relevant by searching the web?

I found #6431 which introduces an option to manually specific the path to the java binary in the runfiles directory. As a work around, I can set this to remotejdk11_linux/bin/java manually.

However, this is quite fragile, as now if we ever make changes to our toolchain setup then end users' fast runs will break

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

No response

@JohnnyMorganz JohnnyMorganz added awaiting-maintainer Awaiting review from Bazel team on issues type: bug labels Jul 5, 2024
@github-actions github-actions bot added product: IntelliJ IntelliJ plugin labels Jul 5, 2024
@sgowroji sgowroji assigned mai93 and unassigned sgowroji, iancha1992 and satyanandak Jul 8, 2024
@sgowroji sgowroji added the lang: java Java rules integration label Jul 8, 2024
@mai93 mai93 added the P3 We're not considering working on this, but happy to review a PR. (No assignee) label Jul 17, 2024
@mai93 mai93 removed their assignment Jul 17, 2024
@mai93 mai93 removed the awaiting-maintainer Awaiting review from Bazel team on issues label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: java Java rules integration P3 We're not considering working on this, but happy to review a PR. (No assignee) product: IntelliJ IntelliJ plugin type: bug
Projects
None yet
Development

No branches or pull requests

5 participants