Skip to content

feat(command): WSL-safe program translation for git/gh - #83

Merged
jwp2987 merged 1 commit into
mainfrom
feat/wsl-program-translation
Aug 5, 2026
Merged

feat(command): WSL-safe program translation for git/gh#83
jwp2987 merged 1 commit into
mainfrom
feat/wsl-program-translation

Conversation

@jwp2987

@jwp2987 jwp2987 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Part of #2 / #11 (WSL program translation).

Zap ships as a Linux ELF that users run inside WSL, where appendWindowsPath = true puts /mnt/c/.../Git/cmd on PATH — so a bare Command::new("git") can resolve to Windows git.exe through WSL interop (slow, mishandles Linux paths, breaks Linux-side hooks). The fork had no WSL handling.

Ports Warp's wsl module: translate_program_for_spawn runs from every Command::new* constructor and, only when is_wsl(), rewrites bare git/gh to the first PATH executable outside /mnt/* (cached). Path-qualified/unknown programs pass through; non-WSL Linux/macOS is untouched (is_wsl() false → early return).

resolve_binary_in_wsl_safe_path is pure and unit-tested without a real WSL host. Ports Warp's 11 wsl_tests.rs. cargo test -p command 11/0 on Linux — fully verified (this is Linux code, not a cfg(windows) blind port).

Part of the WSLENV-allowlist ledger item remains separate (Windows-side env var forwarding).

🤖 Generated with Claude Code

Zap ships as a Linux ELF that users run inside WSL, where the default
`appendWindowsPath = true` puts `/mnt/c/.../Git/cmd` on PATH — so a bare
`Command::new("git")` can resolve to Windows `git.exe` through WSL interop
(dramatically slower, mishandles Linux paths, breaks Linux-side hooks). The
fork had no WSL handling in `crates/command`.

Port Warp's `wsl` module: `translate_program_for_spawn` runs from every
`Command::new*` constructor (async `new`/`new_with_session`/
`new_with_process_group`, blocking `new`) and, only when `is_wsl()`, rewrites
bare `git`/`gh` to the first executable on PATH outside `/mnt/*` (cached for the
process). Path-qualified or unknown programs pass through unchanged, so non-WSL
Linux/macOS behavior is untouched (`is_wsl()` is false → early return).

`resolve_binary_in_wsl_safe_path` is pure and unit-tested without a real WSL
host. Ports Warp's `wsl_tests.rs` (11 tests): /mnt skipping, non-WSL
passthrough, symlinks, non-executable/non-UTF-8 PATH handling, bare-name
recognition. `cargo test -p command` 11/0 on Linux.

Part of #2 / the #11 feature-parity ledger (WSL program translation).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012gDYSHa4oDvQbfungWwG1h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant