question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shell commands don't work in rolling release on Windows any more (Bash not found)

See original GitHub issue

Description of the bug:

When using any rule that uses a shell action (e.g. genrule), the rolling release now hardcodes c:\tools\msys64\usr\bin\bash.exe as location of Bash, no matter where MSys64 is actually installed. Setting BAZEL_SH doesn’t work any more. In the latest release, Bazel would find the MSys tools with or without BAZEL_SH. Maybe commit eeb2e04e52cfad165a1bde33ce2d83a392f53d00 is related since it touches this code. Note that the default installation directory for MSys64 is C:\MSys64, not C:\Tools\MSys64, so I think even as a fallback/default value the filename would be incorrect.

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create an empty WORKSPACE file and the following BUILD file:

genrule(
    name = "foo",
    outs = ["foo.txt"],
    cmd = "echo bar > $@",
)

Then run

SET USE_BAZEL_VERSION=rolling
bazelisk build //:all

No matter whether BAZEL_SH is set or not, Bazel will try to find Bash at c:\tools\msys64\usr\bin\bash.exe, which fails unless it’s actually installed at that location. (The default installation directory is C:\MSYS64, not C:\Tools\MSYS64.)

Which operating system are you running Bazel on?

Microsoft Windows [Version 10.0.17763.2803]

What is the output of bazel info release?

release 6.0.0-pre.20220630.1

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 master; git rev-parse HEAD ?

irrelevant

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
meteorcloudycommented, Oct 7, 2022

OK, I’ll look into this today

0reactions
fmeumcommented, Oct 6, 2022

@meteorcloudy I think that this should be labeled a release blocker. For example, rules_jvm_external uses genrule to generate its @maven “alias” repo, which means that it currently can’t be used on Windows at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bash won't open in Windows 11 - Super User
Tried typing the command (in CMD prompt), "bash". Another post about Bash opening and closing mentioned (first answer by '-Mr Happy') about ...
Read more >
'\r': command not found - .bashrc / .bash_profile - Stack Overflow
The reasons that SHELLOPTS needs to be set in an Windows environment variable instead of a Cygwin environment variable is because that variable...
Read more >
Command Not Found in Bash Fixed - devconnected
The first step to solve this error is to verify that the command you are looking for actually exist on the system. There...
Read more >
How to fix a "Command not found" error in Linux - Red Hat
5 ways to fix "Command not found" errors · 1. Include the path · 2. Add a new path · 3. Copy a...
Read more >
Error message 'source: not found' when running a script
It's dropped, because source is not found. source is a Bash built-in function, and you don't execute the script with bash .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found