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

[Bug]: Error: spawnSync npm.cmd EINVAL when tsp code install #3513

Closed
4 tasks done
archerzz opened this issue Jun 4, 2024 · 3 comments · Fixed by #3522
Closed
4 tasks done

[Bug]: Error: spawnSync npm.cmd EINVAL when tsp code install #3513

archerzz opened this issue Jun 4, 2024 · 3 comments · Fixed by #3522
Assignees
Labels
bug Something isn't working needs-area
Milestone

Comments

@archerzz
Copy link
Member

archerzz commented Jun 4, 2024

Describe the bug

The follow error shows up when executing tsp code install:

PS C:\Users\xxx> tsp code install
TypeSpec compiler v0.56.0

tsp code install

Install VS Code Extension

Options:
  --help      Show help                                                [boolean]
  --debug     Output debug log messages.              [boolean] [default: false]
  --pretty    Enable color and formatting in TypeSpec's output to make compiler
              errors easier to read.                   [boolean] [default: true]
  --version   Show version number                                      [boolean]
  --insiders  Use VS Code Insiders                    [boolean] [default: false]

Error: spawnSync npm.cmd EINVAL
    at Object.spawnSync (node:internal/child_process:1124:20)
    at spawnSync (node:child_process:876:24)
    at run (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@typespec/compiler/dist/src/core/cli/utils.js:59:18)
    at installVsix (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@typespec/compiler/dist/src/core/cli/install-vsix.js:24:5)
    at async installVSCodeExtension (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@typespec/compiler/dist/src/core/cli/actions/vscode.js:6:12)
    at async Object.handler (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@typespec/compiler/dist/src/core/cli/utils.js:25:29) {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawnSync npm.cmd',
  path: 'npm.cmd',
  spawnargs: [ 'install', '--silent', '--prefix', '.', 'typespec-vscode' ]
}

I checked #3243 which fixed a similar issue. But the corresponding issue #3242 has different error stack.

Checking the source codes, looks like we need to add "shell": true here:

const proc = spawnSync(command, commandArgs, finalOptions);
Probably we need to add a property in RunOptions

Reproduction

Use a brand new windows environment. Install typespec 0.56, follow the doc to install vs code plugin.

Checklist

Environment

  • TypeSpec 0.56.0
  • Node v20.14.0
  • OS: Windows 11 enterprise
@archerzz archerzz added the bug Something isn't working label Jun 4, 2024
@pshao25
Copy link
Contributor

pshao25 commented Jun 4, 2024

I met same problem when running rush format for autorest in a devbox.

at Object.spawnSync (node:internal/child_process:1117:20)
at spawnSync (node:child_process:876:24)
at run (C:\Users\xxx\GIT\autorest\eng\scripts\helpers.js:26:50)
at runPrettier (C:\Users\xxx\GIT\autorest\eng\scripts\helpers.js:48:3)
at Object. (C:\Users\xxx\GIT\autorest\eng\scripts\format.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {

@timotheeguerin
Copy link
Member

Seems like a bug but any reason to install via the command line and not the extension in the marketplace?

@archerzz
Copy link
Member Author

archerzz commented Jun 5, 2024

Seems like a bug but any reason to install via the command line and not the extension in the marketplace?

I get used to run on command line, so when I saw the Installation section of readme, I just copied & pasted tsp code install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants