`pre-commit` hook "Bad CPU type in executable" error
- Dominant language
- TypeScript
- Stars
- 21.8k
- Forks
- 10.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 25
Description
### The problem
Testing basic hook functionality isn't working for me. I have `.git/hooks/pre-commit` containing merely this:
```shell
#!/bin/sh
touch HOOK_WAS_HERE.txt
```
On trying to commit anything within the app I get this error:
> fatal: cannot exec '/var/folders/zg/97vbp6vj3d735q_j9_tln6xh0000gn/T/desktop-git-hooks-QeIKaV/pre-commit': Bad CPU type in executable
I've been consulting with a clanker (a paid version, even!) for more than an hour trying to find a solution. Using `/bin/bash` didn't work nor did specifying the architecture to run: `#!/usr/bin/arch -x86_64 /bin/sh`. The script creates `HOOK_WAS_HERE.txt` just fine if I execute it myself; it's only the GitHub app that seems to have issues with it.
At this point the clanker is saying it's some kind of bug in how hooks are executed within the app on old machines like my 2018 Mac Mini -- and that it's time to try another solution outside of the app.
> Even though your GitHub Desktop app says "Intel," it is likely a Universal app itself. When it spawns a child process (the hook), it’s passing an environment variable that says "prefer the latest architecture." On a 2026 Mac system, that "latest" is ARM. Even though your hardware can't run it, the app is mistakenly forcing the shell to try.
I dunno if this is a hallucination given that Cmd-I tells me the GitHub app is "Application (Intel)" in type, but this is what it's telling me.
### Release version
3.5.8 (x64)
### Operating system
macOS 15.7.4
### Steps to reproduce the behavior
1. Be poor and on old hardware like me.
2. Clone some repo.
3. Add `.git/hooks/pre-commit` with the simple contents above.
4. `chmod +x` the new script.
5. Make any change and try to commit it.
6. He's dead, Jim.
### Log files
A relevant bit from today's log:
> 2026-05-01T20:07:31.643Z - info: [ui] [Timing] Action 'create commit' for 'REDACTED/REDACTED' took 0.048s
2026-05-01T20:13:24.550Z - error: [ui] `git commit -F -` exited with an unexpected code: 1.
fatal: cannot exec '/var/folders/zg/97vbp6vj3d735q_j9_tln6xh0000gn/T/desktop-git-hooks-fy7Xoh/pre-commit': Bad CPU type in executable
### Screenshots
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by reproducing the minimal .git/hooks/pre-commit hook in GitHub Desktop 3.5.8 (x64) on Intel macOS 15.7.4 and comparing it with direct execution. Use the logged desktop-git-hooks temporary path to investigate hook execution; no implementation file or test is named, and the architecture explanation is unverified. Done means committing through the app succeeds and creates HOOK_WAS_HERE.txt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, git, macos, shell, typescript
- Domain
- desktop, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 44/100