fix(hooks): warn when the platform has no sh instead of failing silently - #29
Merged
Conversation
epodivilov
marked this pull request as ready for review
July 21, 2026 22:04
Hook commands run via `sh -c`, which native Windows does not provide, so every configured hook failed with an opaque "Failed to execute command". The shell adapter now resolves `sh` on PATH and returns a dedicated SHELL_UNAVAILABLE error. Hook call sites report it once, name how many hooks were skipped, and stop retrying commands that cannot run. Document the hook execution model in the README, including native Windows (cmd.exe / PowerShell) as a known limitation.
epodivilov
force-pushed
the
fix/hooks-windows-warning
branch
from
July 21, 2026 22:07
666463e to
108c8bd
Compare
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.
Problem
Hook commands are executed as
sh -c "<command>". Native Windows has nosh, soBun.spawnthrew, the adapter mapped it to a genericUNKNOWNerror, and every configured hook surfaced asHook failed: "..." - Failed to execute command— once per hook, with no hint about the cause. Windows is a supported target (wt-windows-x64.exe, PowerShell installer), so a documented feature quietly did nothing there.Change
BunShellAdapterresolvesshonPATHonce per instance and returns a dedicatedSHELL_UNAVAILABLEerror when it is missing; the resolved absolute path is used for spawning.runHooksuse case,wt create,wt removesingle and parallel paths) recognise that code, emit a single warning naming how many hooks were skipped, and stop attempting the remaining commands.ui.warnchannel; the spinner now stops with "Hooks skipped" instead of "Hooks completed".User-visible on a shell-less platform:
Behaviour where
shexists (Linux, macOS, Git Bash, WSL) is unchanged.Docs
New "Hook Execution Model" section in the README hooks area: hooks are shell strings by design, run through
sh -cin the worktree, taken from repo config at the same trust level aspackage.jsonscripts — not escaped or sandboxed. It also records the known limitation: nativecmd.exe/ PowerShell hook execution is not supported and not planned.Tests
pnpm typecheck && pnpm lint && pnpm test— 520 tests pass. New coverage: adapter detection (missingsh, lookup memoised, success/non-zero exit paths) and therunHooksskip path, including a shell that becomes unavailable mid-run.