Skip to content

Commit c8517cf

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 c8517cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/git.ts

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

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

1721
/*
@@ -216,7 +220,7 @@ export async function getViaGit(
216220
LC_CTYPE: 'C.UTF-8',
217221
CHERE_INVOKING: '1',
218222
MSYSTEM: 'MINGW64',
219-
PATH: `${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}`
223+
PATH: `${gitForWindowsBinPaths.join(delimiter)}${delimiter}${process.env.PATH}`
220224
},
221225
stdio: [undefined, 'inherit', 'inherit']
222226
}

0 commit comments

Comments
 (0)