-
Notifications
You must be signed in to change notification settings - Fork 19
Description
While working on dennisameling-org/git-for-windows-automation#1, I ran into a weird issue where the setup-git-for-windows-sdk action didn't work, even though I manually installed it in an earlier step (the arm64 image doesn't have GfW installed yet).
I've created a consistent reproducer here, which shows some interesting behavior:
- The first attempt to use
setup-git-for-windows-sdkfails withError: spawn C:/Program Files/Git/cmd/git.exe ENOENT - I then install Git for Windows and add it to the path
- In the second attempt, it actually uses the Git executable to clone
git-sdk-arm64andbuild-extra. However,Creating build-installers artifactstill fails with.tmp/build-extra/please.sh: line 106: git: command not found.
What I did so far to debug this issue
- In Debug Git not found issue dennisameling/setup-git-for-windows-sdk#3, I added some logging to better understand the environment variables that get set by the NodeJS process when it invokes
bash.exefrom theC:/Program Files/Git/usr/binfolder (gitForWindowsUsrBinPath). Here you can see thePATHvalue that NodeJS passes to thebash.exeprocess. Bash itself, however, reports this, where it seems likeC:/Program Files/Git/usr/bingot replaced with simply/usr/bin(I assume this is expected behavior). This folder doesn't seem to contain thegit.exeexecutable. - I have a strong feeling that this issue hasn't popped up before because both GitHub-hosted runners and our self-hosted runners have Git for Windows pre-installed, before (!!!) the GitHub runner agent starts and loads the environment variables from the OS. I added a
which gitline, which resulted in the following:- GitHub-hosted arm64 runner (without Git preinstalled, but installed it in the pipeline itself):
which: no git in (/usr/bin:/bin:/.....) - GitHub-hosted x64 runner (with GfW preinstalled):
/cmd/git(so it somehow found Git in the/cmdfolder, even though it doesn't show in the path??)
- GitHub-hosted arm64 runner (without Git preinstalled, but installed it in the pipeline itself):
What I did to work around the issue
Here, I just explicitly added PATH="/c/Program Files/Git/bin:$PATH" to please.sh, so that it could find something to work with.
Noe that this issue will probably disappear as soon as GfW gets preinstalled on GitHub-hosted ARM64 runners, but I think we could make the setup-git-for-windows-sdk action more resilient to this type of issue moving forward.
I'm happy to implement a fix if you could point me in the right direction. Thanks!