Skip to content

fix: extension bootstrap path mismatch in launchExtension() (#2890)#2957

Open
polajenko wants to merge 1 commit intogithub:mainfrom
polajenko:fix/extension-bootstrap-path-mismatch
Open

fix: extension bootstrap path mismatch in launchExtension() (#2890)#2957
polajenko wants to merge 1 commit intogithub:mainfrom
polajenko:fix/extension-bootstrap-path-mismatch

Conversation

@polajenko
Copy link
Copy Markdown

Summary

Extensions fail to load on both macOS and Windows because the forked child process's security check in index.js expects the bootstrap path under dirname(process.execPath) (the SEA binary directory), but app.js passes a path from the pkg cache (universal/<ver>/preloads/).

This affects all extensions — both user-level and project-level — on CLI v1.0.34 and v1.0.35.

Fixes #2890

Root Cause

macOS Windows (npm)
SEA dir (index.js) darwin-arm64/<ver>/ npm/.../copilot-win32-x64/
Bootstrap from (app.js) universal/<ver>/preloads/ universal/<ver>/preloads/
preloads/ exists in SEA dir? No No

The security check in the embedded index.js:

var z = dirname(fileURLToPath(import.meta.url));  // SEA binary dir
var q = Q?.startsWith(resolve(z, "preloads") + sep) ? Q : undefined;
// q is always undefined → falls through → "Invalid command format"

Proposed Fixes

Option A (smallest change): In launchExtension(), resolve bootstrap path from dirname(process.execPath) instead of cliDistDir, and ship preloads/ in platform npm packages.

Option B (no package changes): Expand the index.js security check to also trust the cliDistDir pkg cache path (passed via env var from parent).

See fix-extension-bootstrap-path.md in this PR for full details and code samples.

Verification

Option A tested locally on Windows 11 (npm install, CLI 1.0.35):

  1. Copied preloads/ to SEA binary directory
  2. Patched minified app.js to prefer dirname(process.execPath)
  3. Both user-level and project-level extensions loaded successfully

Extensions fail to load on macOS and Windows because the forked child
process's security check in index.js expects the bootstrap path under
dirname(process.execPath), but app.js passes a path from the pkg cache
(universal/<ver>/preloads/).

This document describes the root cause analysis and two proposed fixes:
- Option A: resolve bootstrap path from SEA binary dir + ship preloads
  in platform packages
- Option B: expand the security check to trust the pkg cache directory

Fixes github#2890

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@polajenko polajenko requested a review from a team April 24, 2026 14:45
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.

Extensions fail to load — SEA cache directory path mismatch (universal/ vs darwin-arm64/)

1 participant