microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.48k stars 325 forks source link

Call to child_process::spawn requires shell = true under Windows #1582

Closed upwindtec closed 3 weeks ago

upwindtec commented 3 weeks ago

Java-based language servers are launched using a batch file under Windows. Example the Kotlin language server (https://github.com/fwcd/kotlin-language-server) is launched using a batch file that launches the Java runtime using specific parameters. For security reasons, spawning a batch file under Windows is not allowed unless the shell option is used. In the file node/main.js, the shell option can be added around line 422 to resolve the issue: const options = Object.assign({}, command.options); options.shell = true; options.cwd = options.cwd || serverWorkingDir; if (transport === undefined || transport === TransportKind.stdio) { const serverProcess = cp.spawn(command.command, args, options);

and line 275: const execOptions = Object.create(null); execOptions.cwd = serverWorkingDir; execOptions.env = getEnvironment(options.env, false); execOptions.shell = true; const runtime = this._getRuntimePath(node.runtime, serverWorkingDir);

Unless there is another way to add this option without changing the source-code?

Regards,

Robert

dbaeumer commented 3 weeks ago

For the same reasons NodeJS doesn't execute batch files by default anymore I can't pass shell: true by default. You need to set this yourself using this: https://github.com/microsoft/vscode-languageserver-node/blob/main/client/src/node/main.ts#L60