Windows Desktop + WSL: branch switch fails with cannot spawn NUL/post-checkout
## Summary
On Codex Desktop for Windows, switching a WSL-backed repository to main fails because Codex tries to spawn NUL/post-checkout inside WSL.
The UI can still show a previously deleted branch even though the repository's actual HEAD is already on main. Selecting main then produces this toast:
Error switching branch: Already on 'main'
error: cannot spawn NUL/post-checkout: No such file or directory
Codex also pollutes the repository root by creating an untracked NUL/ directory containing Git hook files.
Environment
- Codex Desktop:
26.721.4979.0 - Windows 10 Home 22H2, build
19045.6466 - Repository location: WSL 2 / Ubuntu (
\\wsl.localhost\Ubuntu\home\...) - Git inside WSL:
2.43.0
Steps to reproduce
- Open a Git repository located inside WSL from Codex Desktop on Windows.
- Work on a feature branch and later merge/delete that branch.
- Return to the Codex task. The environment selector may still display the deleted feature branch while
git symbolic-ref --short HEADreportsmain. - Select
mainin the branch selector.
Actual behavior
The branch selector fails with:
Already on 'main'
error: cannot spawn NUL/post-checkout: No such file or directory
The repository contains:
NUL/
??? post-checkout
??? post-commit
??? post-merge
??? pre-push
git config --show-origin --get core.hooksPath returns no configured value, so these files appear to be created/injected by Codex rather than repository configuration.
Expected behavior
- Codex should refresh the branch selector from the repository's real
HEAD. - Selecting the already-active branch should be a no-op, not an error.
- Hook suppression/path handling must be platform-aware:
NULis a Windows device name, but inside WSL it is a relative path. Codex should use/dev/nullor a valid platform-neutral hooks directory when invoking WSL Git. - Codex should not create an untracked
NUL/directory in the repository.
Suspected cause
A Windows-specific null-device value (NUL) is being passed as a Git hooks path while the Git process runs inside WSL. WSL Git interprets it as <repo>/NUL, which leaves hook files in the working tree and later fails to execute NUL/post-checkout.