Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): "npm run package" fails on Windows #4947

Merged
merged 2 commits into from
May 7, 2024

Conversation

rbbarad
Copy link
Contributor

@rbbarad rbbarad commented May 7, 2024

Use shell for execFileSync during extension packaging on Windows OS

Problem

A recent node update has introduced an issue with spawnSync (execFileSync) on Windows. An issue has been filed for this here nodejs/node#52554.

This is affecting the packageExtension step for Windows OS on the latest Node versions (Node v20.12.2), giving the following error:

> ts-node ./scripts/build/handlePackageJson

<ref *1> Error: spawnSync vsce ENOENT
    at Object.spawnSync (node:internal/child_process:1124:20)
    at spawnSync (node:child_process:876:24)
    at Object.execFileSync (node:child_process:919:15)
    at main (C:\Users\rbbarad\Desktop\vscode-toolkit\aws-toolkit-vscode-staging\scripts\package.ts:156:23)
    at Object.<anonymous> (C:\Users\rbbarad\Desktop\vscode-toolkit\aws-toolkit-vscode-staging\scripts\package.ts:181:1)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module.m._compile (C:\Users\rbbarad\Desktop\vscode-toolkit\aws-toolkit-vscode-staging\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\rbbarad\Desktop\vscode-toolkit\aws-toolkit-vscode-staging\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1206:32) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawnSync vsce',
  path: 'vsce',
  spawnargs: [ 'package', '--ignoreFile', '../.vscodeignore.packages' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null
}

Solution

This PR fixes the issue by using a shell to run execFileSync when on Windows OS. This is because vsce is a .cmd file which needs a shell to run.

Testing

  • Ran npm install, npm run compile, npm run package locally. confirmed packaging was successful

Related Issue(s), If Filed

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rbbarad rbbarad requested a review from a team as a code owner May 7, 2024 17:07
scripts/package.ts Outdated Show resolved Hide resolved
@justinmk3 justinmk3 changed the title Use shell for execFileSync during extension packaging on Windows OS fix(build): "npm run package" fails on Windows May 7, 2024
@justinmk3 justinmk3 merged commit 09bfb14 into master May 7, 2024
14 checks passed
@justinmk3 justinmk3 deleted the rbbarad/fix-windows-extension-pkging branch May 7, 2024 18:19
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.

None yet

2 participants