-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Classpath JAR is incorrect when running java_binary remotely on Windows #13484
Comments
Which JDK version are you using? I'm curious because there's a more principled alternative to the 'classpath jar' workaround in the stub script, but it's only going to work with JDK 9: #6354 |
We are using our own prebuilt version of JDK11 for |
/cc @meteorcloudy |
@ruiqimao Thanks for reporting this issue and the reproduce case! I did a little debugging, it's indeed a problem of the Rlocation function. This is what's happening:
I'll try if I can make sure the runfiles dir is always calculated as an absolute path, so it won't cause this problem. |
@meteorcloudy #13559 does appear to fix the issue! |
Cool, then I'll merge that! |
Description of the problem / feature request:
When a java_binary that is used as the executable to a
ctx.actions.run
has a classpath that exceeds the classpath limit for the launcher (7000 by default), the action fails to run remotely, exiting with aClassNotFoundException
:This behavior happens only when:
Workarounds for this issue include:
--singlejar
flag and including_deploy.jar
in the inputs--classpath_limit
Both of these workarounds involve preventing the launcher from creating a classpath jar.
Digging around with the Bazel source code uncovered the following findings:
Classpath:
attribute in the classpath jar is empty when run remotely.java_launcher.cc#L213
).BinaryLauncherBase::Rlocation
(java_launcher.cc#L331
).Rlocation
, it should always return an absolute path.Using a custom build of Bazel, I can confirm that:
Rlocation
are relative when run remotely.blaze_util::AsShortWindowsPath
fixes the problem.This leads me to conclude that somewhere in the pipeline, an absolute path is missing.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
//test/BUILD
//test/test.bzl
//test/pkgXXXXX/Main.java
Create multiple copies, replacing
XXXXX
with a unique number.//test/pkgXXXXX/BUILD
Create multiple copies, replacing
XXXXX
with a unique number.Command
This setup can be generated using generate.py
What operating system are you running Bazel on?
Windows Server 2019 Datacenter, Version 1809
What's the output of
bazel info release
?The text was updated successfully, but these errors were encountered: