feat(command): WSL-safe program translation for git/gh - #83
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2 / #11 (WSL program translation).
Zap ships as a Linux ELF that users run inside WSL, where
appendWindowsPath = trueputs/mnt/c/.../Git/cmdon PATH — so a bareCommand::new("git")can resolve to Windowsgit.exethrough WSL interop (slow, mishandles Linux paths, breaks Linux-side hooks). The fork had no WSL handling.Ports Warp's
wslmodule:translate_program_for_spawnruns from everyCommand::new*constructor and, only whenis_wsl(), rewrites baregit/ghto 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_pathis pure and unit-tested without a real WSL host. Ports Warp's 11wsl_tests.rs.cargo test -p command11/0 on Linux — fully verified (this is Linux code, not acfg(windows)blind port).Part of the WSLENV-allowlist ledger item remains separate (Windows-side env var forwarding).
🤖 Generated with Claude Code