# BUG: "git var GIT_SHELL_PATH" is broken on Windows

3 messages from 2024-07-08 to 2024-07-08. Participants: Phillip Wood, brian m. carlson, Johannes Schindelin.
Thread: https://gitlist.dev/t/61752

## Phillip Wood, 2024-07-08 10:07

Subject: BUG: "git var GIT_SHELL_PATH" is broken on Windows
Message-ID: <cc267962-ca2d-4c4a-9ed8-d40c4d282522@gmail.com>
URL: https://gitlist.dev/e/cc267962-ca2d-4c4a-9ed8-d40c4d282522%40gmail.com

```
Running "git var GIT_SHELL_PATH" on Windows prints "/bin/sh" which is 
not very helpful when the path to the shell is actually 
"C:\Users\gitlab_runner\scoop\apps\mingit-busybox\2.45.2\mingw64\bin\ash.exe"

Support for GIT_SHELL_PATH was added to "git var" in 1e65721227 (var: 
add support for listing the shell, 2023-06-27) with the aim of making it 
possible for external programs to learn the location of the shell used 
to run the command returned by "git var GIT_EDITOR". As the commit 
message notes this is especially helpful on Windows where the shell 
isn't necessarily in $PATH. Unfortunately the implementation simply 
prints SHELL_PATH which is unused on Windows. As 776297548e (Do not use 
SHELL_PATH from build system in prepare_shell_cmd on Windows, 
2012-04-17) explains the location of the shell depends on git's 
installation prefix. For the git-for-windows builds it looks like the 
shell is always in "$GIT_EXEC_PATH/../../bin/" but I'm not sure if that 
is universally true.

It is possible to work around the bug by doing

     git -c 'alias.run-editor=!$(git var GIT_EDITOR)' run-editor

but it would be good to fix "git var GIT_SHELL_PATH" or at least 
document that it is broken on Windows

Best Wishes

Phillip

```

## brian m. carlson, 2024-07-08 10:45

Subject: Re: BUG: "git var GIT_SHELL_PATH" is broken on Windows
Message-ID: <ZovDPbgBS7WJIipz@tapette.crustytoothpaste.net>
URL: https://gitlist.dev/e/ZovDPbgBS7WJIipz%40tapette.crustytoothpaste.net
In-Reply-To: <cc267962-ca2d-4c4a-9ed8-d40c4d282522@gmail.com>

```
On 2024-07-08 at 10:07:17, Phillip Wood wrote:
> Running "git var GIT_SHELL_PATH" on Windows prints "/bin/sh" which is not
> very helpful when the path to the shell is actually
> "C:\Users\gitlab_runner\scoop\apps\mingit-busybox\2.45.2\mingw64\bin\ash.exe"
> 
> Support for GIT_SHELL_PATH was added to "git var" in 1e65721227 (var: add
> support for listing the shell, 2023-06-27) with the aim of making it
> possible for external programs to learn the location of the shell used to
> run the command returned by "git var GIT_EDITOR". As the commit message
> notes this is especially helpful on Windows where the shell isn't
> necessarily in $PATH. Unfortunately the implementation simply prints
> SHELL_PATH which is unused on Windows. As 776297548e (Do not use SHELL_PATH
> from build system in prepare_shell_cmd on Windows, 2012-04-17) explains the
> location of the shell depends on git's installation prefix. For the
> git-for-windows builds it looks like the shell is always in
> "$GIT_EXEC_PATH/../../bin/" but I'm not sure if that is universally true.
> 
> It is possible to work around the bug by doing
> 
>     git -c 'alias.run-editor=!$(git var GIT_EDITOR)' run-editor
> 
> but it would be good to fix "git var GIT_SHELL_PATH" or at least document
> that it is broken on Windows

Ugh.  This was indeed supposed to work, but I no longer have access to a
Windows machine, so we'd need someone who does have one to write up a
patch.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

```

## Johannes Schindelin, 2024-07-08 13:08

Subject: Re: BUG: "git var GIT_SHELL_PATH" is broken on Windows
Message-ID: <cbdae028-db3d-b43e-57ef-52182452f49d@gmx.de>
URL: https://gitlist.dev/e/cbdae028-db3d-b43e-57ef-52182452f49d%40gmx.de
In-Reply-To: <ZovDPbgBS7WJIipz@tapette.crustytoothpaste.net>

```
Hi Phillip & brian,

On Mon, 8 Jul 2024, brian m. carlson wrote:

> On 2024-07-08 at 10:07:17, Phillip Wood wrote:
> > Running "git var GIT_SHELL_PATH" on Windows prints "/bin/sh" which is not
> > very helpful when the path to the shell is actually
> > "C:\Users\gitlab_runner\scoop\apps\mingit-busybox\2.45.2\mingw64\bin\ash.exe"
> >
> > Support for GIT_SHELL_PATH was added to "git var" in 1e65721227 (var: add
> > support for listing the shell, 2023-06-27) with the aim of making it
> > possible for external programs to learn the location of the shell used to
> > run the command returned by "git var GIT_EDITOR". As the commit message
> > notes this is especially helpful on Windows where the shell isn't
> > necessarily in $PATH. Unfortunately the implementation simply prints
> > SHELL_PATH which is unused on Windows. As 776297548e (Do not use SHELL_PATH
> > from build system in prepare_shell_cmd on Windows, 2012-04-17) explains the
> > location of the shell depends on git's installation prefix. For the
> > git-for-windows builds it looks like the shell is always in
> > "$GIT_EXEC_PATH/../../bin/" but I'm not sure if that is universally true.
> >
> > It is possible to work around the bug by doing
> >
> >     git -c 'alias.run-editor=!$(git var GIT_EDITOR)' run-editor
> >
> > but it would be good to fix "git var GIT_SHELL_PATH" or at least document
> > that it is broken on Windows
>
> Ugh.  This was indeed supposed to work, but I no longer have access to a
> Windows machine, so we'd need someone who does have one to write up a
> patch.

Funnily enough, the test suite specifically tested for the faulty `sh`
suffix.

Also, pro-tip: With GitHub Actions and
https://github.com/mxschmitt/action-tmate you can fix compile errors and
other problems directly on the hosted runners, including Windows ones. If
you do not have any access to Windows machines anymore, that's how you can
gain it back. I use this, too, to ensure that my patches work on macOS as
intended, as I do not have access to any other macOS machine.

As to the issue at hand, I offer
https://lore.kernel.org/git/pull.1760.git.1720443778074.gitgitgadget@gmail.com
to address it.

Ciao,
Johannes

```
