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

[Windows] Server initialization failed error #2251

Closed
AndreasADL opened this issue Jul 13, 2023 · 23 comments · Fixed by #2323
Closed

[Windows] Server initialization failed error #2251

AndreasADL opened this issue Jul 13, 2023 · 23 comments · Fixed by #2323

Comments

@AndreasADL
Copy link

AndreasADL commented Jul 13, 2023

I am new to this running Calva for the first time on Windows 11.

I got the following vs-code errors
[Error - 00:45:45] Server initialization failed. Message: Internal error Code: -32603 [object Object] [Error - 00:45:45] Clojure Language Client client: couldn't create connection to server. Message: Internal error Code: -32603 [object Object] [Error - 00:45:47] Connection to server got closed. Server will not be restarted.

Apparently the closure-lsp was successfully downloaded ("Downloaded clojure-lsp to: c:\Users\Andreas Kolb.vscode\extensions\betterthantomorrow.calva-2.0.378\clojure-lsp")

I haven't found a solution through googling it... tried deleting the "extensions/betterthantomorrow.calva-2.0.378" folder and reinstalling the extention, but without success...

@PEZ
Copy link
Collaborator

PEZ commented Jul 14, 2023

Hi! What happens if you run the downloaded clojure-lsp from the command line? (It's not a solution, but we might see some output that could hint at what is going wrong.)

@AndreasADL
Copy link
Author

Ok so I did
cd $HOME\.vscode\extensions\betterthantomorrow.calva-2.0.378
then .\clojure-lsp.exe (or just .\clojure-lsp) which leads to an unresponsive terminal.

It's not frozen in the usual sense, there is still a curser and I can write letters, but other than a new line there is no intelligible output, and the command doesn't terminate...

@PEZ
Copy link
Collaborator

PEZ commented Jul 14, 2023

I think that means that the command works. 😄 You can try .\clojure-lsp --version and it should print the version and then terminate.

But it leaves us with few clues as to what is going wrong... I'll think a bit and see if I can come up with anything to test.

@AndreasADL
Copy link
Author

Hey, I just found the Guide for first starting Calva and actually the cmd+ p"Calva: Fire up getting started REPL" worked, as well as the cmd+ enter execution of the "Hello, world!" program.

Still, when I restart VS code I get the same three error messages.

Also, it may be worth noting that when I first installed Calva I did not have Java installed yet, but after re-installation (including deleting the folders in$HOME\.vscode\extensions) that shouldn't be problematic, should it?

@PEZ
Copy link
Collaborator

PEZ commented Jul 16, 2023

Also, it may be worth noting that when I first installed Calva I did not have Java installed yet, but after re-installation (including deleting the folders in$HOME\.vscode\extensions) that shouldn't be problematic, should it?

No, shouldn't be problematic.

@PEZ
Copy link
Collaborator

PEZ commented Jul 16, 2023

Thanks for updating about the getting started REPL working.

I don't know why clojure-lsp doesn't work. But you can use Calva anyway. There are some features you won't have, but generally things should work. So don't let those error messages get in the way for exploring Clojure. 😄

There is a similar question to yours asked in the #calva channel over at Clojurians Slack, so maybe we will manage to collect clues enough to sort the issue out.

@martyrion
Copy link

Hello, I faced more or less the same issue.
It looks like in my case the problem was that one of the enclosing folders of the project, had non-latin characters in its filename.

I am sending this archive that reproduces the error. Check if you like.
You don't actually need to download it. Just put an "ω" in any folder in the path to your project.

latin.zip

@AndreasADL
Copy link
Author

AndreasADL commented Jul 22, 2023

Hello, I faced more or less the same issue. It looks like in my case the problem was that one of the enclosing folders of the project, had non-latin characters in its filename.

I am sending this archive that reproduces the error. Check if you like. You don't actually need to download it. Just put an "ω" in any folder in the path to your project.

latin.zip

It pains me to say that that appears to be the solution to the problem indeed...
My $HOME directory is "C:\Users\First-Name Second-Name" with a space in the string.

I created a new user with "C:\Users\First-Name-Second-Name" as home dir and here the extension worked fine...
EDIT: ❌I must have gotten something wrong here, I tried reproducing this "fix" the other day, and it didn't work, I got the same error message.

I'm afraid that in my case it will be very difficult to "just rename the path" as I would have to migrate my whole system (correct me if I'm wrong but atm this is the only way I know...)
(I guess it's my own fault for using windows? 😄 😅)

Is there a quick fix I have missed or will I have to live with this?

@PEZ
Copy link
Collaborator

PEZ commented Jul 22, 2023

Is there a quick fix I have missed or will I have to live with this?

You could place your Clojure project somewhere else than under the your user home directory?

@AndreasADL
Copy link
Author

Hey, sorry for getting back to you late.
I have tried all of the following:

  • Place the Clojure project into another directory e.g. C:\Projects (without success)
  • Installing VS Code System-wide (No success, packages etc. remained the same)
  • Changing extensions folder on VS Code as explained here (including placing a fresh portable version of VS Code into C:) without success

None of them worked, and I begin to wonder why, because this strange dependency on the file path should lie somewhere in (Extention Folder, Project Folder, VS Code Installation, ...), shouldn't it?

@PEZ
Copy link
Collaborator

PEZ commented Aug 1, 2023

That's super strange! I could reproduce the problem by putting a project in a path with an ö in it. But I'm on a Mac. My user directory is /Users/pez, so maybe it has to do with that. Maybe the PATH variable gets scanned. Do you have you user directory there?

As for fixing the problem. I've spent a lot of time investigating, and I really don't know how to fix this. It goes wrong deep inside VS Code somewhere. I find no relevant issues on VS Code (at least not when I checked, maybe there's one there now). It might take that we can create a minimal reproduction with a minimal LSP server, so that the VS Code team can have a look. But that will take some time to create.

@bpringe
Copy link
Member

bpringe commented Aug 2, 2023

Have you tried using VS Code Insiders @AndreasADL? It probably won't "fix" your issue, but it's worth a try, I suppose.

@uhlikosaurus
Copy link

Hello,
same problem here. I've been struggling for a few days with turning on clojure-lsp via Calva extension in VSCode. I also tried the option that Calva download the lsp itself, but I had the exact same problem.

It always writes this error:

[Error - 6:18:41 PM] Server initialization failed.
Message: Internal error
Code: -32603
[object Object]
[Error - 6:18:41 PM] Clojure Language Client client: couldn't create connection to server.
Message: Internal error
Code: -32603
[object Object]
[Error - 6:18:43 PM] Connection to server got closed. Server will not be restarted.

OS: Windows 11
Arch: x64

Java:

openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7)
OpenJDK 64-Bit Server VM Temurin-17.0.8+7 (build 17.0.8+7, mixed mode, sharing)

ClojureLSP version:

clojure-lsp 2023.08.06-00.28.06
clj-kondo 2023.07.14-SNAPSHOT

VSC settings:

{ "calva.showDocstringInParameterHelp": true, "calva.clojureLspPath": "C:\Users\uhlik\bin\clojure\bin\clojure-lsp.exe", "editor.fontLigatures": true, "editor.formatOnSave": true, "calva.paredit.defaultKeyMap": "original", "calva.autoOpenJackInTerminal": false, "calva.fmt.configPath": "CLOJURE-LSP", "calva.enableClojureLspOnStart": "never", "calva.prettyPrintingOptions": { "printEngine": "pprint", "enabled": true, "width": 120, "maxLength": 50 }}

image image

I hope this helps.

Regards
Martin Strnad

@PEZ
Copy link
Collaborator

PEZ commented Oct 4, 2023

Thanks, @uhlikosaurus! Let's hope they understand the error over at clojure-lsp/clojure-lsp#1679

@hkjels
Copy link

hkjels commented Oct 5, 2023

This happens for me as well on windows 10 with clean installation of Visual Studio Code, Calva extension, and Clojure-lsp. It does not happen for colleagues on the same projects. Path of the projects does not contain any non-latin characters though

@uhlikosaurus
Copy link

uhlikosaurus commented Oct 5, 2023

Yes, I have tried it on a work PC with windows 10 and also unsuccessfully. LSP with Kate editor worked without any problem, so it really seems to be a calva/VSC bug.

@uhlikosaurus
Copy link

uhlikosaurus commented Oct 6, 2023

Wow, I got it.
I found the output files from LSP in the %appdata%/Local/Temp folder.
clojure-lsp+some large number.out

java.nio.file.InvalidPathException: Illegal char <:> at index 24: C:\Program Files\ElixirC:\Program Files\Erlang OTPC:\Program Files\ElixirC:\Program Files\Erlang OTPC:\Users\uhlik\AppData\Local\Programs\Microsoft VS CodeC:\ghcupC:\Users\uhlik\AppData\Local\Programs\Microsoft VS CodeC:\rakudoC:\rakudo\share\perl6\site\bin

image

(I am sorry, my system is in Czech, so I hope you understand my explanation.)
In the system path (user, not system) labeled Path, several variables were written to one line instead of being written to multiple lines, the screenshot shows how I cleaned up the path. The error from lsp shows what was in the yellow marked line before.

I'm guessing it's a windows bug. As far as I know, variables in windows are separated by semicolons, somehow it didn't work here.

After clearing this path lsp with calva works.

Hope this help <3

@uhlikosaurus
Copy link

I'll check this behavior on my work PC on Monday.

PEZ added a commit that referenced this issue Oct 6, 2023
@PEZ PEZ changed the title Server initialization failed. Clojure Language Client client: couldn't create connection to server. Connection to server got closed. Server will not be restarted. [Windows] Server initialization failed error Oct 6, 2023
@PEZ
Copy link
Collaborator

PEZ commented Oct 6, 2023

Thanks!!! I'm updating the documentation here: https://deploy-preview-2323--calva-docs.netlify.app/

@PEZ PEZ closed this as completed in #2323 Oct 6, 2023
@hkjels
Copy link

hkjels commented Nov 1, 2023

I noticed that this ticket has been closed, but the solution provided doesn't seem to resolve my issue. I've double-checked my PATH variable and it appears to be set up correctly. Additionally, I've cleared all temporary files. Despite these steps, the problem continues.

@hkjels
Copy link

hkjels commented Nov 1, 2023

Upon further review, it turns out that the problem was indeed related to the PATH variable, just in a different way than initially thought. Specifically, I encountered this issue from the installation of Nim using Scoop. My apologies for the confusion.

@PEZ
Copy link
Collaborator

PEZ commented Nov 1, 2023

Thanks for both updates, @hkjels! If you see room for improvement in the docs here: https://calva.io/clojure-lsp/#server-initialization-failed please suggest (or PR the improvement).

@hkjels
Copy link

hkjels commented Nov 2, 2023

Looks good

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

Successfully merging a pull request may close this issue.

6 participants