Skip to content

Conversation

@yuribodo
Copy link

@yuribodo yuribodo commented Feb 6, 2026

Summary

  • Add polyglot .cmd wrappers to 3 official plugins (explanatory-output-style, learning-output-style, ralph-wiggum) that ensure hook .sh scripts execute correctly on Windows when WSL is installed
  • Update hooks.json in each plugin to route through the wrapper instead of calling .sh scripts directly
  • Document the pattern in plugin-dev skill (SKILL.md, patterns.md) with a copyable example for plugin developers

Problem

On Windows with WSL installed (extremely common due to Docker Desktop), bash in PATH resolves to C:\Windows\System32\bash.exe (WSL) instead of Git Bash. Claude Code detects .sh in hook commands and auto-prepends bash, causing all plugin hooks to fail:

WSL ERROR: CreateProcessCommon: execvpe(/bin/bash) failed: No such file or directory

Claude Code correctly identifies Git Bash at startup (Using bash path: "C:\Program Files\Git\bin\bash.exe") but uses generic bash for hook execution.

Solution

A polyglot .cmd file that works in both cmd.exe and bash:

  • Lines starting with :; are labels in cmd.exe (ignored) and no-ops in bash
  • Bash path: execs the target .sh script natively
  • cmd.exe path: explicitly invokes Git Bash at standard installation paths with fallback discovery via where git

No changes to the core binary needed. Existing .sh scripts remain unchanged.

Test Plan

  • Run each .cmd wrapper via cmd /c on Windows — produces valid JSON output
  • Run each .cmd wrapper via bash on Unix-like shell — passes through correctly
  • Verify no behavior change for existing Unix/macOS users (polyglot passthrough)
  • Start Claude Code with the modified plugins — no SessionStart hook error

References

yuribodo and others added 2 commits February 6, 2026 00:03
…tion

On Windows with WSL installed, `bash` resolves to WSL's bash.exe instead
of Git Bash, breaking all plugin hooks that use .sh scripts. Add polyglot
.cmd wrappers that explicitly invoke Git Bash on Windows and pass through
to bash natively on Unix/macOS.

Affected plugins: explanatory-output-style, learning-output-style,
ralph-wiggum.

Fixes anthropics#23556

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add cross-platform hook wrapper documentation to the plugin-dev skill:
- New section in SKILL.md explaining the WSL bash problem and solution
- Pattern 11 in patterns.md with the polyglot wrapper pattern
- Example cross-platform-hook.cmd for plugin developers to copy

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@TStepOne
Copy link

TStepOne commented Feb 6, 2026

👍

@mrmrcode
Copy link

Appreciate the effort

🤖 Generated with Claude Code

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.

[BUG] Windows: Hook .sh auto-detection resolves to WSL bash.exe instead of Git Bash when WSL is installed

3 participants