-
-
Notifications
You must be signed in to change notification settings - Fork 83
[BUG] cog commit fails on Windows with os error 193 when any git hook is installed (including hooks installed by cog itself) #556
Description
Description
cog commit fails on Windows with os error 193 whenever a git hook is
installed — including hooks installed by Cocogitto itself via
cog install-hook. This breaks Cocogitto's own documented functionality
on Windows.
Environment
- OS: Windows (PowerShell)
- Cocogitto version: 7.0.0
Minimal reproduction (no third-party tools needed)
- Add a hook to
cog.tomlexactly as shown in the official documentation:
[git_hooks.commit-msg]
script = """#!/bin/sh
echo "hook works"
"""- Install the hook:
cog install-hook commit-msg
- Run:
cog commit feat "my message"
Actual behavior
Error: IO Error
cause: %1 ist keine zulässige Win32-Anwendung. (os error 193)
Expected behavior
cog commit executes successfully.
Additional reproduction (third-party hook managers)
The same error occurs when hooks are installed by any external tool such as
Lefthook. The content of the hook is irrelevant — the error appears as soon
as any shell script exists in .git/hooks/.
Root cause analysis
Cocogitto installs hooks as shell scripts with a #!/bin/sh shebang.
When executing them, it calls the hook directly via Rust's
std::process::Command without invoking a shell. Windows cannot execute
shebang-based shell scripts as direct processes, resulting in
os error 193 (ERROR_BAD_EXE_FORMAT).
git commit does not have this problem because Git for Windows delegates
hook execution to its bundled sh.exe.
Cocogitto therefore installs hooks that it cannot execute on Windows —
breaking its own documented functionality.
Suggested fix
On Windows, resolve sh.exe from the Git installation and use it to
execute hook scripts, mirroring how Git itself handles hook execution:
// Instead of:
Command::new(hook_path)
// On Windows:
Command::new("sh").arg(hook_path)The sh.exe path can be resolved dynamically, e.g. via git --exec-path
or by locating the Git for Windows installation directory.