git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.38k stars 2.54k forks source link

Error "-c: applet not found" when git should execute external command using MinGit-2.46.0-busybox-64-bit #5121

Closed dodmi closed 1 month ago

dodmi commented 2 months ago

Setup

It's working fine with MinGit-2.45.2-busybox-64-bit

Details

PowerShell 5

git branch

I expected a list of branches in my repo

I get the message -c: applet not found

dscho commented 2 months ago
git branch

This does not reproduce the issue here, it correctly shows the list of branches here.

dodmi commented 2 months ago

Thank you for your quick response. I upgraded from version 2.45.2 to 2.46.0 and didn't change anything else. After you wrote it's working for you, I tried something else: git -P branch is working. But invoking external tools doesn't.

While my settings worked fine with version 2.45.2, git 2.46 seems to have problems to run external programs or reads .gitconfig settings differently.

This worked before:

[core]
pager = \"C:\\Program Files (x86)\\Tools\\less.exe\" --clear-screen --tilde
editor = \"C:\\Program Files (x86)\\Vim\\vim74\\vim.exe\"

git 2.46.0 neither executes less nor vim as it did before.

dscho commented 2 months ago

This worked before:

[core]
pager = \"C:\\Program Files (x86)\\Tools\\less.exe\" --clear-screen --tilde
editor = \"C:\\Program Files (x86)\\Vim\\vim74\\vim.exe\"

Aha! This is not part of the standard setup, and therefore a crucial part of the minimal reproducer.

And since the provenance of that C:\Program Files (x86)\Tools is unclear, and since you are obviously using MinGit interactively (which is not the intended use case), the largest part of the investigation is your own responsibility.

Here is a pointer to get you started: call GIT_TRACE=1 git branch to find out what exact command-line is triggering that error message.

If this does not help, you will need to install Git for Windows' SDK and then bisect via sdk cd git && git bisect start v2.46.0.windows.1 v2.45.2.windows.1 etc.

dodmi commented 2 months ago

Well, I set up my MinGIT ages before and simply replaced the MinGIT folder with any new version. Sorry :'( I set up a simple test now and compared the output of MinGIT 2.45.2 with MinGIT 2.46.0 As pager, I've set "notepad.exe" - just for simplicity.

[core]
pager=notepad.exe

With GIT_TRACE=1 I get: MinGIT 2.45

C:\Repo>"c:\Program Files\MinGIT2.45\cmd\git.exe" branch
19:55:31.437448 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/MinGit2.45/mingw64/bin
19:55:31.453428 git.c:465               trace: built-in: git branch
19:55:31.453428 run-command.c:657       trace: run_command: unset GIT_PAGER_IN_USE; LESS=FRX LV=-c ''\''notepad.exe'\'''

This opens Notepad, as expected.

MinGIT 2.46:

C:\Repo>"c:\Program Files\MinGIT2.46\cmd\git.exe" branch
19:55:42.391835 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/MinGIT2.46/mingw64/bin
19:55:42.407483 git.c:472               trace: built-in: git branch
19:55:42.407483 run-command.c:667       trace: run_command: unset GIT_PAGER_IN_USE; LESS=FRX LV=-c ''\''notepad.exe'\'''
19:55:42.407483 run-command.c:928       trace: start_command: 'C:/Program Files/MinGIT2.46/mingw64/bin/busybox.exe' -c ''\''notepad.exe'\''' ''\''notepad.exe'\'''
-c: applet not found

It seems, git 2.46 invokes busybox with command line parameter -c, but busybox doesn't support such a parameter, hence the misleading error message. busybox shouldn't be prepended at all.

dodmi commented 2 months ago

There's also an ash.exe in mingw64\bin, which supports -c as command line argument and would work. Can I configure git somewhere to use ash.exe instead of busybox.exe?

dodmi commented 1 month ago

Using package MinGit-2.46.0-64-bit.zip, all works as expected, the problem is somewhere around the integration with busybox

dodmi commented 1 month ago

With MinGit 2.46.1 Busybox x64, something changed. But it's still not working in all cases.

[core]
pager=notepad.exe

and

[core]
pager="C:/Windows/notepad.exe"

work fine now, while it didn't work in 2.46. pager = "C:/Program Files (x86)/Tools/less.exe" or pager = "'C:/Program Files (x86)/Tools/less.exe' --clear-screen --tilde" still don't work and busybox -c is executed.

dodmi commented 1 month ago

Well, I switched to MinGit (without Busybox) and all is working as before now. I'm closing this issue as there seems to be no further interest to solve it.