-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error git: command not found
on GitHub-hosted arm64 runner that got GfW installed at runtime
#951
Comments
Bash itself, however, reports this, where it seems like C:/Program Files/Git/usr/bin got replaced with simply /usr/bin (I assume this is expected behavior). It is expected.
That is expected, too.
I think this feeling is correct.
The cloning steps call the |
Maybe this code is the culprit for the behavior where But that does not really match the error message, which looks more as if |
I think it's this
I think it's just bash doesn't have |
The `please.sh` script is supposed to be invoked with the `PATH` that contains a working `git.exe`. However, the way it is currently invoked, only the `/usr/bin/` directory is added to the `PATH`, but not the clang/MINGW directory that contains the native `git.exe`. This does not matter on GitHub-hosted runners because Git for Windows is installed on those runners and therefore `git.exe` is _already_ in the `PATH`. However, on self-hosted runners, Git for Windows may not even be installed, and even if it is, it may not have been added to the `PATH`. Therefore, let's add those clang/MINGW directories. Do not even bother testing whether those directories exist; Those will simply be ignored anyway, and it is the simplest way to guarantee that `please.sh` will find the intended `git.exe`. This fixes git-for-windows#951. Signed-off-by: Johannes Schindelin <[email protected]>
Good point. It happens to work on hosted runners because So we'd need to change this code around from someting like: export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
[...]
PATH: `${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}` to something like: export const gitForWindowsBinPaths =
['clangarm64', 'mingw64', 'mingw32', 'usr'].map(p => `${gitRoot}/${p}/bin`)
[...]
PATH: `${gitForWindowsBinPaths.join(delimiter)}${delimiter}${process.env.PATH}` I pushed something along those lines into my fork as @dennisameling could you please try running this (switching out |
That worked, thank you!!
It doesn't, because the I was working on a similar fix, and ended up extracting the |
Hmm. But that |
It doesn't, indeed. By default, the GitHub Actions Runner doesn't seem to have any flavor of Git pre-installed. It only seems to have NodeJS installed. Having Git pre-installed only seems to be the case on the default GitHub-hosted runners, like Even the |
Huh. I thought it needed Git to run
Hmm. Possibly. Maybe |
Apparently not, as can be seen here:
It falls back to the GitHub REST API if Git isn't installed. However, in my earlier testing, that did cause issues later down the line:
Negative. Looks like that folder doesn't even exist on a fresh installation of the Runner. So it looks like GfW really doesn't come bundled with the runner itself, only NodeJS. |
Okay. Together with other insights I recently had (like: why do we have to clone Git for Windows' minimal SDK over and over again, when we are taking pains to look for the latest revision for which Instead of doing a sparse, partial & shallow clone of the Git for Windows SDK every single time the I'll tell you why: I once looked into doing that, considering GitHub Packages. But they have rather strict retention rules and we definitely do not need to retain anything but the latest working minimal-sdk artifact. (And I don't want to waste resources unnecessarily, even if someone else pays for them.) So I looked into uploading that artifact to Azure Blobs, but had to pull the plug in one big hurry because it threatened to blow my Azure budget. So I gave up on that plan and instead went with the "partial, shallow, sparse clone & then cache" plan. Turns out that other people had the same problem and became much more creative than myself. For example, the MSYS2 project needs to maintain a "srcinfo" cache where it stores information about all the latest package versions that were built and uploaded to their Pacman repository. And they use a GitHub release for that. Where they overwrite the release assets with whatever becomes the current version, over and over and over again. We can do the same! So here's my current plan: Modify the The biggest downside of this strategy is that it won't work with anything else but the git-for-windows/git-sdk-64 repository because it requires that GitHub release, and requires effort to ensure that the release asset(s) are kept up to date. In particular, it won't work with the git-sdk-arm64 repository unless we start running that A slightly smaller downside is that this locks the door for the idea to potentially use the minimal SDK for an arbitrary git-sdk-64 revision. But I never really added the code to enable that, anyway, so that's not such a big deal. In any case, it should be relatively easy to resurrect the code if the need for that feature should arise in the future. |
That makes a lot of sense to me!
Windows itself has had Let me know if I can help with anything! |
In my tests, this indeed works, and it works quite well, and blows Here is step 1: git-for-windows/git-sdk-64#87. Step 2 will be do adjust Step 3 will be to set up the same changes in |
Let me know if I can be of any help there.
I added a scheduled cleanup job here but back then, we decided that we just wanted to rely on webhooks for the time being. So we could probably still add that logic, or accelerate the switch over to GitHub-hosted arm64 runners instead (now in paid GA). I think we'll want to do the latter anyway at some point in the near future, before or after they become freely available for OSS projects (see the linked issue for more details). |
You have a good point. I shouldn't have asked for that commit to be dropped. Here is my attempt to atone: git-for-windows/git-for-windows-automation#93 |
I have a PR in progress that's almost working: git-for-windows/git-sdk-arm64#22 |
And to wrap things up, this PR implements step 2. Spoiler alert: it's incredibly fast! |
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:
setup-git-for-windows-sdk
fails withError: spawn C:/Program Files/Git/cmd/git.exe ENOENT
git-sdk-arm64
andbuild-extra
. However,Creating build-installers artifact
still fails with.tmp/build-extra/please.sh: line 106: git: command not found
.What I did so far to debug this issue
bash.exe
from theC:/Program Files/Git/usr/bin
folder (gitForWindowsUsrBinPath
). Here you can see thePATH
value that NodeJS passes to thebash.exe
process. Bash itself, however, reports this, where it seems likeC:/Program Files/Git/usr/bin
got replaced with simply/usr/bin
(I assume this is expected behavior). This folder doesn't seem to contain thegit.exe
executable.which git
line, which resulted in the following:which: no git in (/usr/bin:/bin:/.....)
/cmd/git
(so it somehow found Git in the/cmd
folder, even though it doesn't show in the path??)What I did to work around the issue
Here, I just explicitly added
PATH="/c/Program Files/Git/bin:$PATH"
toplease.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!
The text was updated successfully, but these errors were encountered: