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

Windows: Java rules require MSYS #6464

Closed
laszlocsomor opened this issue Oct 22, 2018 · 3 comments
Closed

Windows: Java rules require MSYS #6464

laszlocsomor opened this issue Oct 22, 2018 · 3 comments

Comments

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Oct 22, 2018

Description of the problem / feature request:

The Java rules depend on at least on genrule, so they need MSYS on Windows.

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

On a fresh Windows 10:

  1. download Bazel 0.18.0
  2. install the MSVC redistributable DLLs
  3. download and install JDK 8
  4. create a fake msys script as c:\src\tmp\fake-msys\usr\bin\bash.bat that just prints its arguments and exits:
C:\src\tmp>notepad c:\src\tmp\fake-msys\usr\bin\bash.bat

C:\src\tmp>type c:\src\tmp\fake-msys\usr\bin\bash.bat
@echo OFF
echo Fake MSYS, args=(%0 %1 %2 %3 ...)
exit /B 1
  1. Create a workspace with one BUILD rule and one Java file:
C:\src\tmp>type BUILD
java_binary(
  name = "hello_java",
  srcs = ["Hello.java"],
  main_class = "Hello",
)

C:\src\tmp>type Hello.java
public class Hello {
  public static void main(String[] args) {
    System.out.println("hello Java!");
  }
}
  1. in cmd.exe:
C:\src\tmp>set BAZEL_SH=c:\src\tmp\fake-msys\usr\bin\bash.bat

C:\src\tmp>bazel build //:hello_java
...
ERROR: 
C:/users/laszlocsomor/_bazel_laszlocsomor/zovul4l7/external/bazel_tools/tools/jdk/BUILD:202:5: Executing genrule @bazel_tools//tools/jdk:platformclasspath8 failed (Exit 1)
Fake MSYS, args=("C:\src\tmp\fake-msys\usr\bin\bash.bat" -c "source external/bazel_tools/tools/genrule/genrule-setup.sh;  ...)
Target //:hello_java failed to build

The same thing happens even when JAVA_HOME is set.

What operating system are you running Bazel on?

Windows Server 2016 (v1607)

@cushon
Copy link
Contributor

cushon commented Oct 22, 2018

@bazel_tools//tools/jdk:platformclasspath8 isn't genrule at head, fwiw.

@laszlocsomor
Copy link
Contributor Author

Thanks! Indeed, using Bazel built from HEAD, I can make this work -- I replaced my fake Bash with an .exe file I wrote that just prints its arguments and exits 1, then I put it under c:\src\fake-msys\usr\bin\bash.exe, pointed BAZEL_SH at it, and could successfully build the java_binary in the bug report.

@laszlocsomor
Copy link
Contributor Author

See also #6475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants