Skip to content

Commit dfc6162

Browse files
committed
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 #951. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2c7b814 commit dfc6162

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/git.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ const gitRoot = fs.existsSync(externalsGitDir)
1111
? externalsGitDir
1212
: gitForWindowsRoot
1313

14-
export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
14+
const gitForWindowsBinPaths = [
15+
'clangarm64',
16+
'mingw64',
17+
'mingw32',
18+
'usr'
19+
].map(p => `${gitRoot}/${p}/bin`)
20+
export const gitForWindowsUsrBinPath = gitForWindowsBinPaths[gitForWindowsBinPaths.length - 1]
1521
const gitExePath = `${gitRoot}/cmd/git.exe`
1622

1723
/*
@@ -216,7 +222,7 @@ export async function getViaGit(
216222
LC_CTYPE: 'C.UTF-8',
217223
CHERE_INVOKING: '1',
218224
MSYSTEM: 'MINGW64',
219-
PATH: `${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}`
225+
PATH: `${gitForWindowsBinPaths.join(delimiter)}${delimiter}${process.env.PATH}`
220226
},
221227
stdio: [undefined, 'inherit', 'inherit']
222228
}

0 commit comments

Comments
 (0)