Skip to content

! aliases not working in MinGit busybox builds #5184

Open

Description

@ibaidev
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?

    $ git --version --build-options
    git version 2.46.2.windows.1
    cpu: x86_64
    built from commit: 1e20af0e809e08cca5714727dfa0fb50c0c4664d
    sizeof-long: 4
    sizeof-size_t: 8
    shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
    feature: fsmonitor--daemon
    libcurl: 8.10.1
    OpenSSL: OpenSSL 3.2.3 3 Sep 2024
    zlib: 1.3.1
    
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?

    $ cmd.exe /c ver
    Microsoft Windows [Versión 10.0.19044.4529]
    
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

    I am using MinGit with busybox.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

    cmd

  • What commands did you run to trigger this issue?

    1. Download MinGit-2.46.2-busybox-64-bit.zip
    2. Unzip it.
    3. Using cmd, create the following alias:
    $ git config --global alias.hello "!echo 'Hello World'"
    
  • What did you expect to occur after running these commands?

    $ git hello
    Hello World
    
  • What actually happened instead?

    $ git hello
    -c: applet not found
    

Activity

  1. ibaidev commented on Oct 1, 2024

    @ibaidev
    Author

    It seems that it is trying to use busybox as a shell:

    $ set GIT_TRACE=1
    $ git hello
    16:11:54.778289 exec-cmd.c:243          trace: resolved executable dir: C:/Users/user/Downloads/MinGit-2.46.2-busybox-64-bit/mingw64/bin
    16:11:54.793944 git.c:758               trace: exec: git-hello
    16:11:54.793944 run-command.c:667       trace: run_command: git-hello
    16:11:54.793944 run-command.c:928       trace: start_command: git-hello
    16:11:54.793944 run-command.c:667       trace: run_command: 'C:\Users\user\Downloads\MinGit-2.46.2-busybox-64-bit\mingw64\bin\busybox.exe' --help
    16:11:54.793944 run-command.c:928       trace: start_command: 'C:\Users\user\Downloads\MinGit-2.46.2-busybox-64-bit\mingw64\bin\busybox.exe' --help
    16:11:54.825164 run-command.c:667       trace: run_command: 'echo '\''Hello World'\'''
    16:11:54.825164 run-command.c:928       trace: start_command: C:/Users/user/Downloads/MinGit-2.46.2-busybox-64-bit/mingw64/bin/busybox.exe -c 'echo '\''Hello World'\''' 'echo '\''Hello World'\'''
    -c: applet not found
    

    and:

    $ git var GIT_SHELL_PATH
    C:/Users/user/Downloads/MinGit-2.46.2-busybox-64-bit/mingw64/bin/busybox.exe
    

    Shouldn't the shell be something like busybox.exe sh?

  2. jp311 commented on Dec 7, 2024

    @jp311

    run-command.c#L295 has issue.
    If using busybox, you should also add "sh" to execute the command, like "busybox sh -c '...'"

  3. dscho commented on Dec 9, 2024

    @dscho
    Member

    run-command.c#L295 has issue. If using busybox, you should also add "sh" to execute the command, like "busybox sh -c '...'"

    That, or switch to shipping busybox.exe renamed to sh.exe in /mingw64/bin (which will make it act as the default shell), maybe.

  4. zcsizmadia commented on Sep 17, 2026

    @zcsizmadia

    Still reproduces with MinGit-2.55.0.5-busybox-64-bit.zip when the PATH contains only C:\Windows\System32, C:\Windows and MinGit's cmd directory. With GIT_TRACE=1:

    trace: start_command: .../mingw64/bin/busybox.exe -c 'echo Hello World' 'echo Hello World'
    -c: applet not found
    

    Root cause: git_shell_path() looks up sh in the PATH and uses the result as argv[0]. The BusyBox variant ships no sh.exe, so the applet fallback in compat/mingw.c returns the path of busybox.exe itself, and BusyBox reads -c as an applet name. If any other sh.exe happens to be on the PATH (an MSYS2 install, for example) the alias works, which is why this is easy to miss.

    git-for-windows/build-extra#746 ships a copy of busybox.exe as mingw64/bin/sh.exe in the BusyBox-based MinGit, as suggested above. Verified against the extracted 2.55.0.5 zip: ! aliases, clones from local paths, and hooks with #!/bin/sh and #!/bin/bash shebangs all work with the restricted PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions