neo-ltex / vscode-ltex

LTeX: Grammar/spell checker :mag::heavy_check_mark: for VS Code using LanguageTool with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
24 stars 0 forks source link

No longer runs on Windows #88

Open michens opened 1 month ago

michens commented 1 month ago

Copied from https://github.com/valentjn/vscode-ltex/issues/884

Describe the bug New versions of Node require setting "shell: true" when calling spawn/spawnSync on a .bat file such as "ltex-ls.bat".

Steps to reproduce Run on Windows.

Expected behavior That it works.

Sample document N/A

LTeX configuration N/A

"LTeX Language Server" log file No log file created as server never starts

"LTeX Language Client" log file 2024-07-29T17:17:28.190Z Info: Setting LTeX UI language to 'en'. 2024-07-29T17:17:28.190Z Info: Loading i18n messages... 2024-07-29T17:17:28.190Z Info: Loading default i18n messages... 2024-07-29T17:17:28.194Z Info: 2024-07-29T17:17:28.194Z Info: ltex.ltex-ls.path not set. 2024-07-29T17:17:28.194Z Info: Searching for ltex-ls in 'c:\Users...'... 2024-07-29T17:17:28.194Z Info: ltex-ls found in 'c:\Users...'. 2024-07-29T17:17:28.194Z Info: 2024-07-29T17:17:28.194Z Info: Using ltex-ls from 'c:\Users...'. 2024-07-29T17:17:28.194Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set. 2024-07-29T17:17:28.196Z Info: Testing ltex-ls... 2024-07-29T17:17:28.196Z Info: Command: "c:\Users\...\lib\ltex-ls-15.2.0\bin\ltex-ls.bat" 2024-07-29T17:17:28.196Z Info: Arguments: ["--version"] 2024-07-29T17:17:28.196Z Info: env['JAVA_HOME']: undefined 2024-07-29T17:17:28.196Z Info: env['JAVA_OPTS']: "-Xms64m -Xmx512m" 2024-07-29T17:17:28.196Z Error: Test failed. 2024-07-29T17:17:28.196Z Error: Error details: 2024-07-29T17:17:28.201Z Error: Error: spawnSync c:\Users...\lib\ltex-ls-15.2.0\bin\ltex-ls.bat EINVAL 2024-07-29T17:17:28.201Z Error: at Object.spawnSync (node:internal/child_process:1124:20) 2024-07-29T17:17:28.201Z Error: at Object.spawnSync (node:child_process:914:24) 2024-07-29T17:17:28.201Z Error: at DependencyManager. (c:\Users...\dist\extension.js:15912:43) 2024-07-29T17:17:28.201Z Error: at Generator.next () 2024-07-29T17:17:28.201Z Error: at fulfilled (c:\Users...\dist\extension.js:15367:32) 2024-07-29T17:17:28.202Z Info: ltex-ls did not print expected version information to stdout. 2024-07-29T17:17:28.202Z Info: stdout of ltex-ls: 2024-07-29T17:17:28.202Z Info: 2024-07-29T17:17:28.202Z Info: stderr of ltex-ls: 2024-07-29T17:17:28.202Z Info: 2024-07-29T17:17:28.202Z Info: You might want to try offline installation, see https://valentjn.github.io/vscode-ltex/docs/installation-and-usage.html#offline-installation.

Version information

Additional context/information Easy enough to solve by patching extension.js file locally. See https://github.com/node-red/node-red/pull/4652/commits/bd58431603fb4169c1696f6b97a618b1acae5091 for pattern to fix. Will submit PR if this project is active and accepting PRs.

xuestrange commented 1 month ago

same issue.

adwaitrawat commented 1 month ago

seeing same issue.

Cthutu commented 1 month ago

I have exactly the same issue. Not sure how to get around it. For some reason ltex-ls.bat doesn't return version information during start up. But if I run it from the command line with ltex-ls.bat --version, I get:

{
    "ltex-ls": "15.2.0",
    "java": "17.0.10"
}

Not sure what to do now other than uninstall it.

Cthutu commented 1 month ago

Tried pointing ltex.java.path at my base installation and the tests still fail:

2024-08-05T08:22:07.782Z Info: Testing ltex-ls...
2024-08-05T08:22:07.782Z Info:   Command: "c:\\Users\\Matt17\\.vscode-insiders\\extensions\\neo-ltex.ltex-13.1.1\\lib\\ltex-ls-15.2.0\\bin\\ltex-ls.bat"
2024-08-05T08:22:07.782Z Info:   Arguments: ["--version"]
2024-08-05T08:22:07.782Z Info:   env['JAVA_HOME']: "c:\\Users\\Matt17\\.sdkman\\candidates\\java\\current"
2024-08-05T08:22:07.782Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx512m"
2024-08-05T08:22:07.782Z Error: Test failed.
2024-08-05T08:22:07.782Z Error: Error details:
2024-08-05T08:22:07.787Z Error: Error: spawnSync c:\Users\Matt17\.vscode-insiders\extensions\neo-ltex.ltex-13.1.1\lib\ltex-ls-15.2.0\bin\ltex-ls.bat EINVAL
2024-08-05T08:22:07.787Z Error:     at Object.spawnSync (node:internal/child_process:1124:20)
2024-08-05T08:22:07.787Z Error:     at Object.spawnSync (node:child_process:914:24)
2024-08-05T08:22:07.787Z Error:     at DependencyManager.<anonymous> (c:\Users\Matt17\.vscode-insiders\extensions\neo-ltex.ltex-13.1.1\dist\extension.js:14956:45)
2024-08-05T08:22:07.787Z Error:     at Generator.next (<anonymous>)
2024-08-05T08:22:07.787Z Error:     at fulfilled (c:\Users\Matt17\.vscode-insiders\extensions\neo-ltex.ltex-13.1.1\dist\extension.js:14587:58)
2024-08-05T08:22:07.787Z Info: ltex-ls did not print expected version information to stdout.
2024-08-05T08:22:07.787Z Info: stdout of ltex-ls:
2024-08-05T08:22:07.787Z Info: 
2024-08-05T08:22:07.787Z Info: stderr of ltex-ls:
2024-08-05T08:22:07.787Z Info:
Sappique commented 1 month ago

In the issue thread on the valentjin/vscode-ltex repo (https://github.com/valentjn/vscode-ltex/issues/884) people have found a workaround by manually adding the shell: true option to the four spawn / spawnSync calls in the extension.js. This worked for me too.

Using VSCode 1.91 also seems to work, though I haven't tested that.

adwaitrawat commented 1 month ago

In the issue thread on the valentjin/vscode-ltex repo (valentjn#884) people have found a workaround by manually adding the shell: true option to the four spawn / spawnSync calls in the extension.js. This worked for me too.

Using VSCode 1.91 also seems to work, though I haven't tested that.

Yeah, I followed the diff mentioned in the issue and its working for me too. Not sure how this can be resolved without altering any files that can potentially break later down the line.

Slartibartfass2 commented 1 month ago

If somebody wonders, how the diff for neo-ltex looks like:

14946a14947
>                 shell: true,
15045a15047
>             shell: true,
26126c26128,26130
<                     const execOptions = Object.create(null);
---
>                     const execOptions = {
>                         shell: true,
>                     }
26258a26263
>                 options.shell = true;
Cthutu commented 1 month ago

To understand @Slartibartfass2 's diff, just do a search for spawn to find all the places you need to set shell to true.

thangckt commented 1 month ago

any update so far? Thanks.

rebekaburnett commented 1 month ago

Those codes on the diff above actually give the line numbers where we are supposed to add/change the code. 14946a14947:

14946: This is the line number in the original file after which a change is made.
a: This stands for "add." It indicates that lines are being added.
14947: This is the line number in the new file where the addition starts.

Here are my old and new files, if that helps. extension_new.js.txt extension_old.js.txt

Making these changes did fix the problem for me, but I had to exit VSCode and start again to take effect.

vahandr commented 1 week ago

There is another fork vscode-ltex-plus which, if I understand correctly, says that it fixes this problem.