Skip to content

fix(core): probe global npm roots when resolving copilot cli#1038

Merged
christso merged 3 commits intomainfrom
fix/1036-copilot-win-resolve
Apr 11, 2026
Merged

fix(core): probe global npm roots when resolving copilot cli#1038
christso merged 3 commits intomainfrom
fix/1036-copilot-win-resolve

Conversation

@christso
Copy link
Copy Markdown
Collaborator

Summary

Fixes spawn copilot ENOENT on Windows when @github/copilot is installed globally via npm install -g. resolvePlatformCliPath() now probes common global npm install roots (APPDATA/npm on Windows, /usr/local, homebrew, ~/.npm-global on Unix, plus any npm_config_prefix override) and checks both the hoisted and nested @github/copilot/node_modules layouts.

Closes #1036

Red/green UAT (Windows)

Running resolvePlatformCliPath() from a cwd outside the workspace (so the local walk-up cannot match) against an unchanged global copilot install:

Red (main @ ddc44e8):

$ bun -e "import { resolvePlatformCliPath } from '.../copilot-utils.ts'; console.log(resolvePlatformCliPath())"
undefined

With executable: copilot this falls through to spawn('copilot')ENOENT, matching the issue repro.

Green (this branch):

resolved: C:\Users\Christopher.Tso\AppData\Roaming\npm\node_modules\@github\copilot-win32-x64\copilot.exe

Tests

  • packages/core/test/evaluation/providers/copilot-utils-resolve.test.ts — 3 new tests covering the %APPDATA%\npm\node_modules layout, npm_config_prefix, and the nested @github/copilot/node_modules layout.
  • Full core suite (bun run test): 1479 pass / 0 fail.
  • Pre-push hooks (build, typecheck, lint, test, validate) all green.

Test plan

  • Unit tests for each probed root
  • Manual resolve check on Windows against real global install (red → undefined, green → copilot.exe)
  • Optional: verify on macOS/Linux with a global install under /usr/local/lib/node_modules

Windows copilot-cli targets failed with `spawn copilot ENOENT` when the
`@github/copilot` package was installed globally via `npm install -g`.
`import.meta.resolve` and the local node_modules walk-up could not find
the platform binary, so the resolver fell back to plain `copilot`, which
is not directly spawnable (the PATH entry is a `.ps1`/`.cmd` shim).

`resolvePlatformCliPath()` now probes common global npm install roots
(APPDATA/npm on Windows, /usr/local, homebrew, ~/.npm-global on Unix,
plus any `npm_config_prefix` override), checking both the hoisted and
nested `@github/copilot/node_modules` layouts before giving up.

Closes #1036

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 10, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ef483a
Status: ✅  Deploy successful!
Preview URL: https://3c28d1e9.agentv.pages.dev
Branch Preview URL: https://fix-1036-copilot-win-resolve.agentv.pages.dev

View logs

christso and others added 2 commits April 11, 2026 13:25
The tests mutated process.env/cwd and silently no-opped on non-Windows
runners, giving little real coverage beyond the manual red/green UAT
documented on the PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Repeatable manual acceptance check for #1036. Run from outside the repo
so the local node_modules walk-up cannot mask a regression. Exits
non-zero when `resolvePlatformCliPath()` returns undefined.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@christso christso marked this pull request as ready for review April 11, 2026 03:57
@christso christso merged commit 9dacc56 into main Apr 11, 2026
4 checks passed
@christso christso deleted the fix/1036-copilot-win-resolve branch April 11, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: copilot-cli should auto-resolve global copilot.exe instead of falling back to spawn('copilot')

1 participant