Repository navigation
Agent suggestions
Public previewDescription
With chat.useClaudeHooks: true, a Claude-format plugin with a hook command of bash "${CLAUDE_PLUGIN_ROOT}/scripts/ensure-jira-cli.sh" fails to execute with Copilot. But it succeeds with the Claude extension for VS Code on the same machine, from the same hooks.json file.
VS Code hook log:
/bin/bash: d:sourcereposagentic-marketplacepluginsjira-release/scripts/ensure-jira-cli.sh: No such file or directory
Three things differ between the two hosts, measured with a diagnostic script run from the hook itself:
| Claude Code Extension | GitHub Copilot | |
|---|---|---|
| interpreter | Git Bash — MINGW64_NT-10.0-26200, bash 5.3.15 |
WSL2 — /usr/bin/bash, bash 5.1.16 |
CLAUDE_PLUGIN_ROOT env var in hook process |
D:/source/repos/agentic-marketplace/plugins/jira-release |
unset |
${CLAUDE_PLUGIN_ROOT} substituted into the command |
forward slashes | backslashes |
| result | hook runs | hook fails |
Each of those is written up separately below, since they are independently fixable.
Steps to reproduce
- On Windows with both WSL2 and Git for Windows installed, set
chat.useClaudeHooks: true. - Create a Claude-format plugin (has
.claude-plugin/plugin.json) in a local marketplace directory, e.g.D:\source\repos\agentic-marketplace. - In the plugin's
hooks/hooks.json, declare a hook whose command is:{ "type": "command", "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/ensure-jira-cli.sh\"", "shell": "bash" } - Put any script at
<plugin>/scripts/ensure-jira-cli.sh. - Load the plugin from the local marketplace and trigger the hook event in an agent session.
- Read the hook output in the Copilot hook log.
Expected
The hook runs the script, as documented: ${CLAUDE_PLUGIN_ROOT} expands to the plugin's absolute path in a form the selected interpreter can resolve, and CLAUDE_PLUGIN_ROOT is also present in the hook process environment.
Actual
/bin/bash: d:sourcereposagentic-marketplacepluginsjira-release/scripts/ensure-jira-cli.sh: No such file or directory — the path's separators are gone, the command runs under WSL bash rather than Git Bash, and CLAUDE_PLUGIN_ROOT is not set in the process.
The same hooks.json, same machine, same plugin, executed by Claude Code instead, succeeds. That control is what makes this a harness defect rather than a plugin misconfiguration.
1. Interpreter selection: a bare bash reaches WSL, not Git Bash
shell: "bash" / a command starting with bash resolves through PATH to C:\Windows\System32\bash.exe, the WSL launcher. This is not fixable by reordering PATH: microsoft/WSL#13277 (closed) documents that CreateProcess gives the system directory precedence over PATH, so System32\bash.exe wins regardless of where Git Bash sits. The choice therefore has to be made by the hook executor.
For comparison, Claude Code's hooks documentation states that shell-form hooks use "Git Bash on Windows" (https://code.claude.com/docs/en/hooks), and the measured behavior matches that statement. VS Code's hooks documentation does not state which shell runs a hook command, on Windows or on any other platform, so there is no documented contract to check an implementation against. #312314 points at extensions/copilot/src/platform/chat/node/hookExecutor.ts hardcoding the Windows shell, which looks like the same code path.
2. Path form and quoting: backslashes survive substitution, quotes do not
The substituted value of ${CLAUDE_PLUGIN_ROOT} uses backslashes. The hooks.json does quote it — bash "${CLAUDE_PLUGIN_ROOT}/scripts/ensure-jira-cli.sh" — but a level of quoting is lost somewhere between the JSON and the interpreter, so bash receives the path unquoted, consumes each backslash as an escape character, and produces d:sourcereposagentic-marketplace....
Verified independently under WSL bash on the same machine: a quoted Windows path keeps its backslashes and simply fails to resolve (a different error), while an unquoted one is mangled in exactly the way the hook log shows. The mangling is therefore evidence that the quotes are stripped upstream of bash, not that bash mishandled a quoted argument.
Claude Code substitutes the same variable with forward slashes, so even if its quoting behaved identically there would be nothing for bash to consume. Emitting a POSIX-style path would defuse this defect on its own; preserving the author's quoting would defuse it independently.
3. CLAUDE_PLUGIN_ROOT does not reach the hook process
VS Code expands this token to the plugin's absolute path at runtime and also sets a
CLAUDE_PLUGIN_ROOTenvironment variable for the hook process.
Measured: a script launched by a plugin-declared hook reports CLAUDE_PLUGIN_ROOT as unset. Under Claude Code the same script sees it set. This means the documented fallback — reading the env var instead of relying on token substitution — is not available, so defect 2 has no workaround from inside the script.
Hypothesis, not a finding: because the interpreter is WSL (defect 1), Windows environment variables do not cross the interop boundary unless named in WSLENV, which would explain the variable disappearing even if the harness does set it on the spawned process. I have not confirmed this; it is offered only as a lead, and the observation stands regardless of the cause.
Additional finding: ${...} substitution is name-exact and destroys shell parameter expansion
Writing ${CLAUDE_PLUGIN_ROOT:-.} in a hook command substitutes to the empty string:
/bin/bash: /scripts/ensure-jira-cli.sh: No such file or directory
So the harness treats CLAUDE_PLUGIN_ROOT:-. as a single unknown variable name and consumes the whole brace expression, rather than substituting the known variable and leaving the rest to the shell. Consequence: no standard shell parameter expansion (:-, :+, %, #) can be used anywhere in a hook command, because any brace expression containing an operator silently becomes empty. That also removes the natural defensive idiom (${CLAUDE_PLUGIN_ROOT:-$PWD}) that would otherwise paper over defect 3.
Workaround (works today — not a proposed fix)
{
"type": "command",
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/x.sh\"",
"windows": "bash ./scripts/x.sh",
"cwd": "${CLAUDE_PLUGIN_ROOT}",
"shell": "bash"
}Verified on this machine:
cwddoes expand${CLAUDE_PLUGIN_ROOT}correctly, and WSL interop auto-translates the working directory to/mnt/d/....- The
windowsoverride is honored inside a Claude-formathooks.json. This is undocumented — the docs describewindowsonly for the native and Copilot hook formats. - Claude Code ignores both
windowsandcwdand usescommand, so a single hook definition serves both hosts.
The asymmetry that makes this work is worth noting for whoever fixes defect 2: cwd travels through the process-spawn API as a structured value, while command travels through a string parser. The value is intact by the time it reaches the OS; only the string path mangles it.
Related issues
- [WSL] Agent plugin hooks fail: Windows-style
CLAUDE_PLUGIN_ROOTpath is passed to Linux/bin/shwithout normalization #313201 — closed as a duplicate of an unnamed issue; same backslash consumption, reported as still reproducing. - Plugin hooks can't invoke relative bundled scripts #307478 — open; same hook path-resolution area.
- Agent Hooks dont work when Windows Powershell is restricted on workstation #312314 — open;
hookExecutor.tshardcodes the Windows shell, which is the code path behind defect 1. - Placeholder for
bash.exemesses withCreateProcessWSL#13277 — closed; documents theCreateProcesssystem-directory precedence that makesPATHordering an ineffective workaround for defect 1. - [BUG] Native installer on Windows: bash hooks resolve to WSL bash.exe instead of Git Bash, causing TUI hang with broken timeout anthropics/claude-code#37634 and [BUG] Windows + WSL: VS Code extension fails to detect Git Bash and always picks System32 bash.exe anthropics/claude-code#21800 — bot-closed; the same WSL-vs-Git-Bash resolution problem in Claude Code's own installer/extension, included as prior art on the ambiguity of a bare
bashon Windows.
Environment
- Windows 11 Pro 10.0.26200
- WSL2 installed (Linux 6.18.35.2-microsoft-standard-WSL2) and Git for Windows installed
chat.useClaudeHooks: true- Plugin loaded from a local marketplace at
D:\source\repos\agentic-marketplace - Git Bash reported by the diagnostic as
MINGW64_NT-10.0-26200, bash 5.3.15; WSL bash as/usr/bin/bash, bash 5.1.16
All measurements in this report come from direct observation on a single Windows machine that has both WSL2 and Git Bash installed. I have not tested a machine with only one of the two, nor any other Windows build.
Activity