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

Can't start Metals server with JDK with cyrillic characters in the path #1509

Open
divijan opened this issue May 19, 2024 · 7 comments
Open

Comments

@divijan
Copy link

divijan commented May 19, 2024

Unable to start Metals extension with cyrillic characters in path under Windows
Cannot find java executable in path with cyrillic characters in it.

Metals Extension output:

Metals version: 1.3.1
Using coursier located at C:\Users\до\.metals\cs.exe //here my two-character cyrillic username is displayed correctly, I just changed it for security reasons
C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\bin\java -version:
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.412-b08, mixed mode)
Found java executable under C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\bin\java.exe that resolves to C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\bin\java.exe
C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\bin\java -version:
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_412-b08
C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\bin\java -version:
)
OpenJDK 64-Bit Server VM (Temurin)(build 25.412-b08, mixed mode)
No installed java with version 17 found. Will fetch one using coursier.
Coursier: openjdk version "17" 2021-09-14
OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)
Using Java Home: C:\Users\??\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin17-binaries\releases\download\jdk-17%252B35\OpenJDK17-jdk_x64_windows_hotspot_17_35.zip\jdk-17+35 //first time I see ?? instead of cyrillic characters
[Error - 5:47:06 PM] Metals client: couldn't create connection to server.
Launching server using command C:\Users\??\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin17-binaries\releases\download\jdk-17%252B35\OpenJDK17-jdk_x64_windows_hotspot_17_35.zip\jdk-17+35\bin\java failed. Error: spawn C:\Users\??\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin17-binaries\releases\download\jdk-17%252B35\OpenJDK17-jdk_x64_windows_hotspot_17_35.zip\jdk-17+35\bin\java ENOENT

To Reproduce:

  1. Do not have the necessary version of Java installed manually
  2. Go to 'File/Open Folder' and choose any folder with sbt project
  3. Click on 'Go to output' in the error alert with title 'Metals client: couldn't create connection to server.' at the right bottom corner of the VSCode window
  4. See the error message

Expected behavior

VS Code should be able to start the server because the java executable is there, the launcher can't seem to understand the cyrillic characters in the path.

Installation:

  • Operating system: Windows 10 22H2
  • VSCode version: 1.89.1
  • VSCode extension version: 1.34.0
  • Metals version: (found in VSCode settings, under metals.serverVersion) 1.3.1

Additional context

After I have 'officially' installed JDK 17 under Program Files, the problem has shifted its shape to this:

Metals version: 1.3.1
Using coursier located at C:\Users\до\.metals\cs.exe //again, obfuscated the cyrillic username
C:\Program Files\Eclipse Adoptium\jdk-17.0.11.9-hotspot\bin\java -version:
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)
Using Java Home: C:\Program Files\Eclipse Adoptium\jdk-17.0.11.9-hotspot\
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 6:05:42 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 6:05:42 PM] Connection to server got closed. Server will restart.
true
[Error - 6:05:42 PM] Metals client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 6:05:43 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 6:05:43 PM] Connection to server got closed. Server will restart.
true
[Error - 6:05:43 PM] Metals client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Could not launch Metals Language Server:
Pending response rejected since connection got disposed
Release notes was not shown: not showing release notes since they've already been seen for your current version
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 6:05:43 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 6:05:43 PM] Connection to server got closed. Server will restart.
true
[Error - 6:05:43 PM] Metals client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 6:05:43 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 6:05:43 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 6:05:43 PM] Connection to server got closed. Server will restart.
true
[Error - 6:05:43 PM] Metals client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 6:05:43 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 6:05:44 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 6:05:44 PM] The Metals server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 6:05:44 PM] Metals client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 6:05:44 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

I found a similar problem described here. It is claimed to be fixed, but apparently not for all cases.

Search terms

Launching server using command ... failed., Error: Spawn ... ENOENT, cyrillic

@tgodzik
Copy link
Contributor

tgodzik commented May 20, 2024

Thanks for reporting! I might have a potential fix in #1510 though we had some issues with adding properties to native image before. Will need to confirm.

@tgodzik
Copy link
Contributor

tgodzik commented May 29, 2024

Looks like we couldn't add the java properties automatically since there seems to be a bug with coursier native image in Windows. Could you try adding JAVA_OPTS variable with "-Dfile.encoding=UTF-8" set? Let's see if that helps.

The alternative is to use old jar launcher when this happens.

@divijan
Copy link
Author

divijan commented May 29, 2024

I've set this variable through control panel and it didn't help. Tried option with and without quotes. When I install Java 17 as a normal Windows package, I get the error described in #366. Is it caused by the same glitch in coursier?

@tgodzik
Copy link
Contributor

tgodzik commented May 29, 2024

It's an issue with encoding, if we set it it should work correctly, but there seems to be an issue here with setting it. I am doing a workaround in the PR linked here.

@divijan
Copy link
Author

divijan commented Aug 25, 2024

Updated to metals 1.3.5 and metals-vscode 1.39.0. With or without Java 17 installed, the error messages are the same, corresponding to what I wrote above. Seems to me if you are a developer, writing your username in cyrillic characters in Windows is a bad idea. Had something else fail because of this yesterday.

@tgodzik
Copy link
Contributor

tgodzik commented Aug 26, 2024

Exactly the same? I hoped that the workaround would help, but then I will need to reproduce it locally on a windows machine 🤔

@divijan
Copy link
Author

divijan commented Aug 28, 2024

Pretty much. With Java 17 not installed, exactly the same save the versions, and with Java installed, very little difference. Do you want me to produce the actual output?

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

No branches or pull requests

2 participants