From dfc61629e561fb6d80dbadbb0c716d594dbce021 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 10 Sep 2024 11:46:19 +0200 Subject: [PATCH] Fix the `PATH` with which `please.sh` is invoked 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 https://github.com/git-for-windows/setup-git-for-windows-sdk/issues/951. Signed-off-by: Johannes Schindelin --- src/git.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/git.ts b/src/git.ts index 87fd60c7..5718547b 100644 --- a/src/git.ts +++ b/src/git.ts @@ -11,7 +11,13 @@ const gitRoot = fs.existsSync(externalsGitDir) ? externalsGitDir : gitForWindowsRoot -export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin` +const gitForWindowsBinPaths = [ + 'clangarm64', + 'mingw64', + 'mingw32', + 'usr' +].map(p => `${gitRoot}/${p}/bin`) +export const gitForWindowsUsrBinPath = gitForWindowsBinPaths[gitForWindowsBinPaths.length - 1] const gitExePath = `${gitRoot}/cmd/git.exe` /* @@ -216,7 +222,7 @@ export async function getViaGit( LC_CTYPE: 'C.UTF-8', CHERE_INVOKING: '1', MSYSTEM: 'MINGW64', - PATH: `${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}` + PATH: `${gitForWindowsBinPaths.join(delimiter)}${delimiter}${process.env.PATH}` }, stdio: [undefined, 'inherit', 'inherit'] }