Skip to content

Conversation

@ronakj
Copy link
Contributor

@ronakj ronakj commented Jan 8, 2024

Due to how spawn works, having spaces in command paths will lead it to being detected as separate arguments. Enclosing the command path in quotes allows correct working of spawn.

Fixes #201211

Tested on Windows and Linux, don't have macos machine so not able to test there.

@ronakj ronakj changed the title Fixes tsserver crashing when using custom node path Jan 8, 2024
@mjbvz mjbvz added this to the December / January 2024 milestone Jan 8, 2024
@mjbvz mjbvz enabled auto-merge (squash) January 8, 2024 16:34
mjbvz
mjbvz previously approved these changes Jan 8, 2024

const childProcess = execPath ?
child_process.spawn(execPath, [...execArgv, tsServerPath, ...runtimeArgs], {
child_process.spawn(`"${execPath}"`, [...execArgv, tsServerPath, ...runtimeArgs], {
Copy link
Member

Choose a reason for hiding this comment

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

I think you should instead do JSON.stringify(execPath) which will handle quotes in the path as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Updated and tested again on Windows/Linux.

auto-merge was automatically disabled January 9, 2024 02:46

Head branch was pushed to by a user without write access

@ronakj ronakj requested review from TylerLeonhardt and mjbvz January 9, 2024 02:48
@mjbvz mjbvz merged commit c1bc541 into microsoft:main Jan 9, 2024
@ronakj ronakj deleted the spawn-quotes branch January 10, 2024 04:55
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants