Bazel transitions result in unix bash path returned on windows host
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
I'm attempting to get windows tests to pass on rules_oci. This module uses many transitioned targets.
Building case4_transition with Bazel 8.3.1 or 8.4.1 on Windows:
```
# Case 4: Transition an oci_image and feed to oci_tarball
oci_image(
name = "case4",
architecture = "arm64",
os = "linux",
)
platform_transition_filegroup(
name = "case4_transition",
srcs = [":case4"],
target_platform = "//examples:linux_arm64",
)
```
results in ctx.toolchains["@bazel_tools//tools/sh:toolchain_type"].path returning /bin/bash instead of C:\msys64\usr\bin\bash.exe as set in BAZEL_SH envvar. This results in the bat wrappers generated for windows failing with invalid path.
Is there any way to get the @bazel_tools//tools/sh:toolchain_type without it being interfered by the transition?
This is only an issue with bazel 8; bazel 7.6.1 returns the windows bash.exe
Thanks! Chris
### Which category does this issue belong to?
_No response_
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
_No response_
### Which operating system are you running Bazel on?
_No response_
### What is the output of `bazel info release`?
_No response_
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
```text
```
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with the case4_transition example and the ctx.toolchains["@bazel_tools//tools/sh:toolchain_type"].path entry point. Reproduce it on Windows with Bazel 8.3.1 or 8.4.1, compare the result with Bazel 7.6.1, and trace how the transition affects the shell toolchain. Done means the transitioned target returns the configured Windows bash.exe path rather than /bin/bash and its generated wrappers work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100