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

Use shell for execFileSync during extension packaging #552

Merged
merged 1 commit into from
May 6, 2024

Conversation

rbbarad
Copy link
Contributor

@rbbarad rbbarad commented May 6, 2024

Use shell for execFileSync during extension packaging

Problem

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

This is affecting our packageExtension step (locally, Windows, Node v20.12.2), giving the following error:

Creating deployment vsix
Packaging with:C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\node_modules\.bin\tfx.cmd extension create --root C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\package --output-path C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\package --manifests C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\package\vss-extension.json
Error: spawnSync C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\node_modules\.bin\tfx.cmd EINVAL
    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 packagePlugin (C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\build-scripts\packageExtension.ts:145:9)
    at Object.<anonymous> (C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\build-scripts\packageExtension.ts:156:1)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module.m._compile (C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\node_modules\ts-node\src\index.ts:858:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\node_modules\ts-node\src\index.ts:861:12)
    at Module.load (node:internal/modules/cjs/loader:1206:32)

Solution

This PR fixes the issue by using a shell to run child_process execFileSync. This solution approach was suggested here: nodejs/node#52554 (comment)

Related Issue(s), If Filed

Testing

  • Ran fullBuild locally. confirmed packaging was successful

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rbbarad rbbarad requested a review from a team as a code owner May 6, 2024 22:57
Copy link

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great explanation! One important detail to note: this is because tfx is a .cmd file, which actually needs a shell. This is one of the rare cases where shell: true is necessary.

@rbbarad rbbarad merged commit dffc4f3 into master May 6, 2024
2 checks passed
@rbbarad rbbarad deleted the rbbarad/fix-exec-file-sync branch May 6, 2024 23:27
justinmk3 pushed a commit to aws/aws-toolkit-vscode that referenced this pull request May 7, 2024
Problem:
Node v20.12.2 has introduced an issue with spawnSync (execFileSync) on Windows:
nodejs/node#52554

```
> 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:
Set the "shell" flag 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:
- aws/aws-toolkit-azure-devops#552
- nodejs/node#52554
ROunofF pushed a commit to ROunofF/aws-toolkit-azure-devops that referenced this pull request May 10, 2024
A recent node update has introduced an issue with spawnSync (execFileSync) on Windows. This fixes the issue by using a shell to run child_process execFileSync. This is because tfx is a .cmd file, which actually needs a shell. This is one of the rare cases where shell: true is necessary.
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