Skip to content

[WSL] Agent plugin hooks fail: Windows-style CLAUDE_PLUGIN_ROOT path is passed to Linux /bin/sh without normalization #313201

Closed as duplicate

Description

Generate by Copilot Chat

Environment

Value
OS Windows 11 + WSL2 (Ubuntu)
VS Code 1.117.0
GitHub Copilot Chat 0.45.x
Remote WSL remote (vscode-server)
Affected plugin mem0ai/mem0 mem0-plugin (installed on Windows side)

Description

When using GitHub Copilot Chat via WSL remote, agent plugin hooks fail with a "not found" error. The root cause is that Copilot Chat's hook runner injects CLAUDE_PLUGIN_ROOT using the Windows local installation path (e.g. c:\Users\<username>\.vscode\agent-plugins\...\mem0-plugin), then passes that path directly to WSL's /bin/sh without any path normalization (e.g. converting to /mnt/c/... or a WSL-side equivalent).

Because /bin/sh in Linux treats backslashes as escape characters, the path c:\Users\<username>\.vscode\... gets its backslashes consumed, resulting in a mangled string like c:Users<username>.vscode... that is treated as a command name — and immediately fails with not found.

The plugin itself is not at fault: its hooks.json correctly uses ${CLAUDE_PLUGIN_ROOT}/scripts/on_user_prompt.sh (a relative expansion). The bug is entirely in the hook runner's path injection.


Steps to Reproduce

  1. Install any agent plugin (e.g. mem0ai/mem0) on the Windows host (i.e. plugin dir is c:\Users\<username>\.vscode\agent-plugins\...).
  2. Open VS Code and connect to a WSL remote via the WSL extension.
  3. Open an Agent Chat session (any workspace).
  4. Submit any user prompt.
  5. Observe the "UserPromptSubmit" hook failure in the Copilot Chat Hooks log.

Expected Behavior

The hook runner should detect that the current execution environment is WSL, and either:

  • Convert the Windows plugin path to its WSL-accessible equivalent (/mnt/c/Users/<username>/...), or
  • Use a WSL-side plugin installation path if available, or
  • Skip hook execution gracefully when the plugin path is not accessible in the current shell environment.

Actual Behavior

Hooks fail immediately with:

/bin/sh: 1: c:Users<username>.vscodeagent-pluginsgithub.commem0aimem0mem0-plugin/scripts/on_user_prompt.sh: not found

From the Copilot Chat Hooks log (GitHub Copilot Chat Hooks.log), the hook runner is executing:

{
  "command": "c:\\Users\\<username>\\.vscode\\agent-plugins\\github.com\\mem0ai\\mem0\\mem0-plugin/scripts/on_user_prompt.sh",
  "cwd": {
    "fsPath": "/home/<username>/projects/my-workspace",
    "scheme": "file"
  },
  "env": {
    "CLAUDE_PLUGIN_ROOT": "c:\\Users\\<username>\\.vscode\\agent-plugins\\github.com\\mem0ai\\mem0\\mem0-plugin"
  },
  "timeout": 5
}

Note that cwd.fsPath is correctly a Linux path (/home/<username>/...), confirming the hook is running inside WSL. But command and CLAUDE_PLUGIN_ROOT are still Windows paths.


Root Cause Analysis

There appear to be two distinct problems combined:

Problem 1 — Wrong path origin:
The hook runner uses the plugin's Windows local installation path for CLAUDE_PLUGIN_ROOT and command, even though the execution context (shell, cwd) is already WSL. The runner does not detect the WSL remote environment and select the appropriate plugin path.

Problem 2 — No path normalization before shell execution:
The Windows path (c:\Users\...) is passed as-is to /bin/sh without:

  • Converting drive notation (C:\) → /mnt/c/
  • Escaping or quoting backslashes

Linux /bin/sh treats \ as an escape character in an unquoted context, silently consuming all backslashes. The resulting "command" becomes an unrecognizable string, which fails as not found.


Plugin hooks.json for Reference

The plugin itself uses only ${CLAUDE_PLUGIN_ROOT}-relative paths and is not responsible for the bad path:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "${CLAUDE_PLUGIN_ROOT}/scripts/on_user_prompt.sh",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

Affected Hooks

All hooks in the plugin are affected (since all use ${CLAUDE_PLUGIN_ROOT}):

  • SessionStart → on_session_start.sh
  • UserPromptSubmit → on_user_prompt.sh
  • Stop → on_stop.sh
  • PreToolUse → block_memory_write.sh
  • PreCompact → on_pre_compact.sh, on_pre_compact.py
  • TaskCompleted → on_task_completed.sh

Suggested Fix

In the hook runner, before spawning the shell process:

  1. Detect WSL remote: check whether the current execution context is WSL (e.g. via process.env.WSL_DISTRO_NAME, or by inspecting the remote authority of the active workspace).
  2. Normalize the plugin path: if running in WSL and CLAUDE_PLUGIN_ROOT is a Windows path (matches ^[A-Za-z]:\\), convert it to its /mnt/<drive>/... equivalent before injecting it into the environment and command string.
  3. Fallback: if the normalized path still does not exist in WSL, emit a warning rather than attempting to execute an invalid command.

Additional Notes

  • The bug is 100% reproducible every time a prompt is submitted in a WSL remote session with any Windows-installed agent plugin.
  • The failure is logged as NonBlockingError, so the chat session continues — but all hooks are silently skipped, meaning features that depend on hooks (e.g. mem0 memory retrieval on each prompt) never execute.
  • The cwd is correctly resolved to the WSL path, suggesting path normalization is already applied for the working directory but not for CLAUDE_PLUGIN_ROOT / command.

Activity

  1. added
    chat-ext-issue
    on Apr 29, 2026
  2. added
    *duplicate
    on Apr 30, 2026
  3. vs-code-engineering commented on Apr 30, 2026

    @vs-code-engineering
    Contributor

    Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

    Happy Coding!

  4. kilianpaquier commented on Jun 2, 2026

    @kilianpaquier

    Hello Connor Peet (@connor4312) Paul (@pwang347), could you indicate from which issue this one is duplicated ? On vscode 1.122.1 the issue still exists and it's quite annoying since all plugins using this substitution cannot be used with WSL or remote base developments.

    Already tried the potential workaround "GitHub.copilot-chat": "workspace" in remote.extensionKind.

  5. locked and limited conversation to collaborators on Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicatechat-ext-issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions