Skip to content

CLI cannot execute hooks shipped with plugins #3659

Closed as duplicate
Closed as duplicate

Description

@brandonh-msft

Describe the bug

As of 1.0.57, I am unable to issue any prompts to GHCP CLI w/o them failing on preToolUse hook exceptions.

Logs show myriad failures like:

2026-06-03T18:51:15.906Z [DEBUG] [hook stderr] The argument '.github/hooks/governance-audit/audit-session-start.ps1' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2026-06-03T18:51:15.907Z [DEBUG] [hook stdout] 
Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
                  [-Command { - | <script-block> [-args <arg-array>]
                                | <string> [<CommandParameters>] } ]
                  [-CommandWithArgs <string> [<CommandParameters>]
                  [-ConfigurationName <string>] [-ConfigurationFile <filePath>]
                  [-CustomPipeName <string>] [-EncodedCommand <Base64EncodedCommand>]
                  [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
                  [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
                  [-NoProfileLoadTime] [-OutputFormat {Text | XML}]
                  [-SettingsFile <filePath>] [-SSHServerMode] [-STA]
                  [-Version] [-WindowStyle <style>]
                  [-WorkingDirectory <directoryPath>]

       pwsh[.exe] -h | -Help | -? | /?

PowerShell Online Help https://aka.ms/powershell-docs

All parameters are case-insensitive.
2026-06-03T18:51:16.068Z [ERROR] Hook execution failed: HookExitCodeError: Hook command failed with code 1

across numerous hook files.

Affected version

1.0.57+

Steps to reproduce the behavior

Install one or more plugins (which ship hooks as part of their functionality) into the CLI.
Send a prompt to the CLI with the plugin active & loaded

Expected behavior

Prompt is processed

Additional context

I have my Copilot Home and cache dirs set to my dev drive (d:\.copilot and d:\.copilot\cache, respectively)

Activity

  1. added theissue type on Jun 3, 2026
  2. added
    area:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    on Jun 3, 2026
  3. brandonh-msft commented on Jun 3, 2026

    @brandonh-msft
    Author

    The root of this issue appears to be in the way plugins ship hooks and hooks get invoked by the CLI.

    E.g. consider a plugin marketplace repo like:

    .github
      plugin
        marketplace.json
    plugins
      example-plugin
        .github
          hooks
            example-hook
              my-script.ps1
          plugin
            hooks.json
    

    where the hooks.json would have a definition to point to something in the example-hook like:

    {
      "version": 1,
      "hooks": {
        "sessionStart": [
          {
            "type": "command",
            "powershell": "pwsh -NoProfile -ExecutionPolicy Bypass -File .github/hooks/example-hook/my-script.ps1",
            "cwd": ".",
            "env": {
              "ENV_VAR": "sample_value"
            },
            "timeoutSec": 10
          }
        ]
      }
    }

    on session start, with this plugin active, the CLI:

    • reads the hooks.json
    • attempts to invoke the hook based on the path in the plugin which, of course, fails because the plugin - once installed into GHCP CLI - lives at $COPILOT_HOME/cache/marketplaces/<repo-slug>/plugins/example-plugin so it won't find the hook at simply .github/hooks/... resulting in the cited "not found" exception.
  4. changed the title [-]1.0.57+ broken due to missing preToolUse hook files[/-] [+]CLI cannot execute hooks shipped with plugins[/+] on Jun 3, 2026
  5. brandonh-msft commented on Jun 3, 2026

    @brandonh-msft
    Author

    I tried removing the cwd property to no avail.

  6. brandonh-msft commented on Jun 4, 2026

    @brandonh-msft
    Author

    Setting cwd to ${PLUGIN_ROOT} (an as-yet-undocumented env var injected at runtime) appears to solve the problem.

    Suggested fix(es):

    • Document PLUGIN_ROOT
    • Make it the default if cwd is not specified in the JSON (I tried removing it altogether and execution still failed)
  7. patniko commented on Oct 26, 2026

    @patniko
    Collaborator

    Thanks for the report! This is the same issue as #2540, so I'm closing this one as a duplicate. Please follow that issue for updates and add any extra details there.

    Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions