Skip to content

Commit

Permalink
fix: Look for bash in (git root)/usr/bin not (git root)/bin
Browse files Browse the repository at this point in the history
This is to help support running them with a shell from the Git for
Windows SDK, which, relative to the directory where it's installed
in, provides a `usr/bin` directory with a `bash.exe` executable,
like the same-named directory in a non-SDK full installation of Git
for Windows via the installer or PortableGit or or via package
managers such as `scoop` that repackage PortableGit, but unlike
those other installations does not provide a `bin` directory.

Inside the MSYS2 "Git Bash" provided as part of the Git for
Windows SDK, there are both `/bin` and `/usr/bin` directories, but
this not related to the `bin` subdirectory of the root of the
installation. On both regular Git for Windows "Git Bash" and Git
for Windows SDK "Git Bash" environments, `/bin` in the environment
is mounted to refer to the same directory as `/usr/bin`. In both,
this is separate from `(git root)/bin` as accessed outside that
environment.

For example, in an SDK "Git Bash":

    $ mount
    C:/git-sdk-64 on / type ntfs (binary,noacl,auto)
    C:/git-sdk-64/usr/bin on /bin type ntfs (binary,noacl,auto)
    C:/Users/ek/AppData/Local/Temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
    C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)
    $ cygpath -w /bin /usr/bin
    C:\git-sdk-64\usr\bin
    C:\git-sdk-64\usr\bin

And in a non-SDK "Git Bash":

    $ mount
    C:/Users/ek/AppData/Local/Temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
    C:/Users/ek/scoop/apps/git/2.48.1 on / type ntfs (binary,noacl,auto)
    C:/Users/ek/scoop/apps/git/2.48.1/usr/bin on /bin type ntfs (binary,noacl,auto)
    C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)
    $ cygpath -w /bin /usr/bin
    C:\Users\ek\scoop\apps\git\2.48.1\usr\bin
    C:\Users\ek\scoop\apps\git\2.48.1\usr\bin

The former has another `bin` directory alongside the `usr` directory
on disk, containing shims for `git.exe`, `sh.exe`, and `bash.exe`,
while the latter does not, but in neither case does `/bin` inside
Git Bash refer to it. This other `bin` directory was formerly used
to find `bash.exe` to run test fixture scripts.

A possible reason to continue using `(git root)/bin` would be if
the shims modify the environment in a way that makes the fixtures
operate better.
  • Loading branch information
EliahKagan committed Feb 23, 2025
1 parent bf2f8df commit 68121af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ fn bash_program() -> &'static Path {
.map(OsString::from)
.map(|mut raw_path| {
// Go down to where `bash.exe` usually is. Keep using `/` separators (not `\`).
raw_path.push("/bin/bash.exe");
raw_path.push("/usr/bin/bash.exe");
raw_path
})
.map(PathBuf::from)
Expand Down

0 comments on commit 68121af

Please sign in to comment.