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

"Couldn't start client Yang Language Server" on windows #95

Open
hujun-open opened this issue Sep 6, 2024 · 11 comments
Open

"Couldn't start client Yang Language Server" on windows #95

hujun-open opened this issue Sep 6, 2024 · 11 comments
Labels

Comments

@hujun-open
Copy link

Yangster version: 2.3.2
vscode: 1.93.0
OS: windows 11

[Error - 1:53:34 PM] Starting client failed
Error: spawn EINVAL
at ChildProcess.spawn (node:internal/child_process:421:11)
at Object.spawn (node:child_process:800:9)
at c:\Users\junhu.vscode\extensions\typefox.yang-vscode-2.3.2\extension\pack\extension.js:1:92428

I tried with openjdk 11, 21, 22, microsoft build openjdk, oracle jdk, same error

but it works fine if use vscode with WSL2 (e.g. open YANG file in WSL), with openjdk 11 installed in WSL2

@andre-brizido
Copy link

I have the same problem on windows and with
OpenJDK 64-Bit Server VM Microsoft-7208460 (build 11.0.18+10-LTS, mixed mode),
VS CODE 1.93.1
latest yangster version available

@vinsworldcom
Copy link

Could this be the issue:

nodejs/node#52681
nodejs/node#52554

Needs {shell: true} - I tried adding this but I don't really know what I'm doing. Also tried to launch something other than yang-language-server.bat to no avail.

Cheers.

@vinsworldcom
Copy link

vinsworldcom commented Oct 18, 2024

I seem to have fixed this. First off, need a file in:

%USERPROFILE%\.yang\yang.settings:

{
    "yangPath": "/usr/share/yang/modules"
}

Where the path is the root of your Yang modules locations. For me, they are in 'C:\usr\share\yang\modules', but I'm using the "unix"-like path which seems to work fine.

Next, you need to add the {shell:true} to the 'extension.js' file, slightly before position 92366 (for me) or where ever the error line:

at c:\Users\junhu.vscode\extensions\typefox.yang-vscode-2.3.2\extension\pack\extension.js:1:92428

indicates. There, you'll find:

r=Object.assign({},t.options);

I changed that to:

r=Object.assign({shell:true},t.options);

And now the plugin shows the function outlines and creates diagrams!

Cheers.

@dhuebner dhuebner added the bug label Oct 25, 2024
@dhuebner
Copy link
Member

@vinsworldcom
Thanks for investigation. Seems to be a Windows issue, right? I'm on mac and will need some time to get a fix ready.

@vinsworldcom
Copy link

@dhuebner , yes, from the 2 Node.js links I reference above, seems a new Node.js setting prevents it from launching Windows .bat or .cmd files directly without setting the {shell: true} property. Assuming somewhere along the recent VSCode upgrades, it started using this new Node.js version as I remember Yangster working fine for me last year and when I returned to it this year (more NETCONF/YANG work popped up), it was "broke".

Not sure you need to worry about the 'yang.settings' file, but it may be nice to make note of that in the README so Windows users know what file to create at what directory path for the Language Server to validate.

I've been happily working with my fix above for a week or so with no ill effects. Of course, not sure of the "proper" way to fix this as I'm not a VSCode extension author or even know much about it.

Cheers.

@dhuebner
Copy link
Member

@vinsworldcom
The problem is that we are not launching processes directly, it must be one of the dependencies that need to be updated I think.

@vinsworldcom
Copy link

The problem is that we are not launching processes directly

Not sure what that means. Who creates the file:

%USERPROFILE%\extensions\typefox.yang-vscode-2.3.2\extension\pack\extension.js

Isn't that from this plugin? That is the file that I'm editing and that is the file that is launching the ".vscode\extensions\typefox.yang-vscode-2.3.3\server\bin\yang-language-server.bat" file. Launching that BAT file is what is generating the error - unless you make the {shell: true} edit to the the 'extension.js' file I indicate above.

Cheers.

@thefans1
Copy link

I seem to have fixed this. First off, need a file in:

%USERPROFILE%.yang\yang.settings:

{
    "yangPath": "/usr/share/yang/modules"
}

Where the path is the root of your Yang modules locations. For me, they are in 'C:\usr\share\yang\modules', but I'm using the "unix"-like path which seems to work fine.

Next, you need to add the {shell:true} to the 'extension.js' file, slightly before position 92366 (for me) or where ever the error line:

at c:\Users\junhu.vscode\extensions\typefox.yang-vscode-2.3.2\extension\pack\extension.js:1:92428

indicates. There, you'll find:

r=Object.assign({},t.options);

I changed that to:

r=Object.assign({shell:true},t.options);

And now the plugin shows the function outlines and creates diagrams!

Cheers.

For me, I only had to add shell:true to the failed Object.assign({},t.options) at the indicated error position (e.g. line 1, char 92428) in extension.js, then things start to work again. I didn't have to do the path thing. Nevertheless, big thanks for these clear steps!

@senlog
Copy link

senlog commented Jan 27, 2025

The issue still occurs with YANGSTER 2.3.3. The above workaround of updating shell: true seems not working.
Is there any other workaround for this? Thanks in advance.

Pls find below the VS code details:
Version: 1.96.4 (user setup)
Commit: cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba
Date: 2025-01-16T00:16:19.038Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

@vinsworldcom
Copy link

It works for me on that exact setup - Yangster 2.3.3 and VS Code 1.96.4.

@senlog
Copy link

senlog commented Jan 28, 2025

Thank you. The issue was due to incorrect JAVA_HOME path. With the correct JAVA_HOME path and updating the extensions.js with the above suggested workaround ( Object.assign({shell:true},t.options) ), it works fine. Thanks @vinsworldcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants