Skip to content

Commit

Permalink
Fix the PATH with which please.sh is invoked
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Sep 10, 2024
1 parent 2c7b814 commit c8517cf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ 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`

/*
Expand Down Expand Up @@ -216,7 +220,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']
}
Expand Down

0 comments on commit c8517cf

Please sign in to comment.