Repository navigation
CLI cannot execute hooks shipped with plugins #3659
Copy link
Copy link
Closed as duplicate
Labels
area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows TerminalWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agentsPlugin system, marketplace, hooks, skills, extensions, and custom agents
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows TerminalWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agentsPlugin system, marketplace, hooks, skills, extensions, and custom agents
Activity
brandonh-msft commentedon Jun 3, 2026
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:
where the hooks.json would have a definition to point to something in the
example-hooklike:{ "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:
$COPILOT_HOME/cache/marketplaces/<repo-slug>/plugins/example-pluginso it won't find the hook at simply.github/hooks/...resulting in the cited "not found" exception.[-]1.0.57+ broken due to missing preToolUse hook files[/-][+]CLI cannot execute hooks shipped with plugins[/+]brandonh-msft commentedon Jun 3, 2026
I tried removing the
cwdproperty to no avail.brandonh-msft commentedon Jun 4, 2026
Setting
cwdto${PLUGIN_ROOT}(an as-yet-undocumented env var injected at runtime) appears to solve the problem.Suggested fix(es):
cwdis not specified in the JSON (I tried removing it altogether and execution still failed)patniko commentedon Oct 26, 2026
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.