Skip to content

Bazel transitions result in unix bash path returned on windows host #27310

@peakschris

Description

@peakschris

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 ?


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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions