Skip to content

Windows,Bash detection: do not detect Git Bash #5751

Closed

Description

@laszlocsomor

Description of the problem / feature request:

When BAZEL_SH envvar is not defined and Bazel searches for a suitable bash.exe, it should not look for Git Bash nor should it recommend installing it as a Bash implementation.

Git Bash does not support the full set of bintools that MSYS2 Bash does, nor does Git Bash support Pacman to install those tools. Git Bash is therefore unsuitable as a general-purpose Bash for Windows.

Even worse, if you have both Git Bash and MSYS Bash installed, they may collide if you run one's binaries from the other (see repro below).

Bazel should only look for MSYS2 Bash and recommend only that.

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

  1. Have both Git Bash and MSYS2 Bash installed, have paths to them that have no space characters:

    C:\src\tmp>mklink /j C:\git "C:\Program Files\Git"
    Junction created for C:\git <<===>> C:\Program Files\Git
    
  2. In MSYS2 Bash install "zip" by running pacman -Syu zip.

  3. Set "BAZEL_SH" envvar to point to Git Bash, put Git then MSYS on the PATH:

    BAZEL_SH=C:\git\usr\bin\bash.exe
    PATH=C:\git\usr\bin;C:\msys64\usr\bin
    
  4. Build a genrule that runs zip.

    C:\src\tmp>type BUILD
    genrule(
        name = "foo",
        outs = ["foo.txt"],
        cmd = ("echo \"DEBUG: $$(cygpath -w $$(which bash))\" ; " +
               "echo \"DEBUG: $$(cygpath -w $$(which zip))\" ; " +
               "zip > $@")
    )
    
    C:\src\tmp>c:\src\bazel-releases\0.16.0\bazel.exe build --verbose_failures //:foo.txt
    INFO: Analysed target //:foo.txt (0 packages loaded).
    INFO: Found 1 target...
    SUBCOMMAND: # //:foo [action 'Executing genrule //:foo']
    cd C:/users/laszlocsomor/_bazel_laszlocsomor/zovul4l7/execroot/__main__
      SET PATH=C:\git\usr\bin;C:\git\bin;C:\git\usr\bin;C:\msys64\usr\bin
      C:/git/usr/bin/bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; echo "DEBUG: $(cygpath -w $(which bash))" ; echo "DEBUG: $(cygpath -w $(which zip))" ; zip > bazel-out/x64_windows-fastbuild/genfiles/foo.txt
    ERROR: C:/src/tmp/BUILD:107:1: Executing genrule //:foo failed (Exit 127): bash.exe failed: error executing command
      cd C:/users/laszlocsomor/_bazel_laszlocsomor/zovul4l7/execroot/__main__
      SET PATH=C:\git\usr\bin;C:\git\bin;C:\git\usr\bin;C:\msys64\usr\bin
      C:/git/usr/bin/bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; echo "DEBUG: $(cygpath -w $(which bash))" ; echo "DEBUG: $(cygpath -w $(which zip))" ; zip > bazel-out/x64_windows-fastbuild/genfiles/foo.txt
    DEBUG: C:\git\usr\bin\bash.exe
    DEBUG: C:\msys64\usr\bin\zip.exe
          1 [main] zip (6740) C:\msys64\usr\bin\zip.exe: *** fatal error - cygheap base mismatch detected - 0x180318410/0x1802FF410.
    This problem is probably due to using incompatible versions of the cygwin DLL.
    Search for cygwin1.dll using the Windows Start->Find/Search facility
    and delete all but the most recent version.  The most recent version *should*
    reside in x:\cygwin\bin, where 'x' is the drive on which you have
    installed the cygwin distribution.  Rebooting is also suggested if you
    are unable to find another cygwin DLL.
    Target //:foo.txt failed to build
    INFO: Elapsed time: 1.160s, Critical Path: 0.70s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully
    

What operating system are you running Bazel on?

Windows 10

What's the output of bazel info release?

C:\src\tmp>c:\src\bazel-releases\0.16.0\bazel.exe info release
release 0.16.0

Activity

  1. self-assigned this
    on Aug 3, 2018
  2. added
    P2
    P1
    and removed
    P2
    on Aug 3, 2018
  3. added a commit that references this issue on Aug 3, 2018
  4. added a commit that references this issue on Aug 8, 2018
  5. added a commit that references this issue on Aug 9, 2018
  6. added a commit that references this issue on Sep 14, 2018
  7. added a commit that references this issue on Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1platform: windowstype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions