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

LanguageClient ServerOptions not spawning when Server in Path #358

Closed
nikeee opened this issue Jun 6, 2018 · 3 comments
Closed

LanguageClient ServerOptions not spawning when Server in Path #358

nikeee opened this issue Jun 6, 2018 · 3 comments
Milestone

Comments

@nikeee
Copy link
Contributor

nikeee commented Jun 6, 2018

I am developting an extension that uses the LanguageClient class to provide a connection to a language server. The language server is installed globally on the OS and can be started using a <command> as it is in $PATH (installed via npm -g i <package>).

Now, the client fails to start the server. My first approach was using these server options:

const serverOptions: Executable = {
    command: "<command>",
    args: ["--stdio"],
}

This does not work, as child_process#spawn does not get the environment variables. This is the relevant section in the code:
https://github.com/Microsoft/vscode-languageserver-node/blob/583ba3878faa9e550461337afefb1618505a4601/client/src/main.ts#L397-L405

My second attempt was to pass process.env as env option:

const serverOptions: Executable = {
	command: "<command>",
	args: ["--stdio"],
	options: {
		env: process.env,
	}
};

This also did not work. I also tried to pass cwd: undefined via options.

One thing that worked for me was to use shell: true in options. However, both declarations of ExecutableOptions do not include a shell?: boolean:

https://github.com/Microsoft/vscode-languageserver-node/blob/583ba3878faa9e550461337afefb1618505a4601/client/src/main.ts#L37-L42
https://github.com/Microsoft/vscode-languageserver-node/blob/c7d5ab633672f5b38886ee54f5dd10c3a8d3646d/client/src/client.ts#L190-L195

But child_process#spawn's options does (ref to docs).

As this behaviour is rather unintuitive to me, I think this might be a bug or or there is some documentation missing on this. I just want to start <command> --stdio to use it as a language server. According to this issue it should suffice to provide options: { cwd: undefined, env: process.env }. But it does not seem to work. It works with options: { shell: true } only, but shell is not included in ExecutableOptions.

  • OS: Windows 10
  • Dependencies:
    • "vscode": "^1.1.18",
    • "vscode-languageclient": "^4.2.1"
@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2018

Yes, I see the point. The thing is that npm -g i very likely installs a shell script and that script can't be run using spwan without using the shell option.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2018

For now cast the options to any and set the shell property. It will be passed to spawn correctly.

@dbaeumer dbaeumer added this to the June 2018 milestone Jun 7, 2018
@nikeee
Copy link
Contributor Author

nikeee commented Jun 7, 2018

Thanks!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants