scalameta / metals-vscode

Visual Studio Code extension for Metals
https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview
Apache License 2.0
297 stars 74 forks source link

Metals does not start anymore on Windows in VS Code since the VS Code extension v1.30.0 #1488

Closed sjrd closed 2 months ago

sjrd commented 3 months ago

Describe the bug

I (automatically) updated Metals in VS Code to the latest release from April 15 on a Windows machine. Now Metals just ... does not start anymore. No "Starting Metals". The Metals tab shows the "New Scala project" and "Start Metals" blue buttons, but clicking on them does not do anything. No logs that I can find either. No .metals directory. It's almost as if it is not even there. I don't even get syntactic help like auto-indent on Enter after an =.

Things I tried:

On my Linux machine at work I haven't observed any issue.

Expected behavior

Er ... at least show me an error message I guess? Ideally successfully start.

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

v1.3.0

Extra context or search terms

No response

sjrd commented 3 months ago

Downgrading to the VS Code extension v1.29.0 solved the issue, even though it uses Metals 1.3.0 anyway. So this seems to be related to v1.30.0 of the VS Code extension, in fact.

tgodzik commented 2 months ago

It looks like we have a timeout inside one of the dependencies which causes the Metals never to find proper Java home. I removed that library in the prerelease, could you try it out?

tgodzik commented 2 months ago

@sjrd could you try the latest prerelease?

sjrd commented 2 months ago

I haven't had much time on a Windows machine since my report. I can try tomorrow evening.

smarkess commented 2 months ago

I have the same issue on Mac. Switching to pre-release didn't work. Only downgrading to 1.29 works

tgodzik commented 2 months ago

@SebastianMarkowski what shows up in your logs? It should not hang the same way since we removed the library that was hanging.

tgodzik commented 2 months ago

I also just merged another fix that will fall back to java on PATH. So that should be even safer, do let us know what shows up for you if that still doesn't work.

If it works I will release 1.31.0 later on.

smarkess commented 2 months ago

@tgodzik Still not working. In output tab I get

Metals version: 1.2.2
Fetching coursier
Coursier: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Coursier: 0     0    0     0    0
Coursier: 0      0      0 --:--:-- --:--:-- --:--:--     0
Coursier: 0     0    0     0    0     0      0
Coursier: 0 --:--:-- --:--:-- --:--:--     0
Coursier: 67 19.2M   67 13.0M    0     0  12.1M      0
Coursier: 0:00:01  0:00:01 --:--:-- 12.1M
Coursier: 100 19.2M  100 19.2M    0     0  15.4M      0  0:0
Coursier: 0:01  0:00:01 --:--:-- 35.9M
Coursier: gzip: (stdin): trailing garbage ignored
Failed to fetch coursier. You may want to try installing coursier manually and adding it to PATH.
Error: Process exited with code 2
Release notes was not shown: not showing release notes since they've already been seen for your current version
tgodzik commented 2 months ago

Looks like it's another issue and the coursier fails to properly download :thinking: What is you operating system?

tgodzik commented 2 months ago

Ach ok nvm, I see it's mac

tgodzik commented 2 months ago

This might have been a problem with a download, we could add a retry, does it happen every time for you?

smarkess commented 2 months ago

Every single time. I checked pre-release versions one by one and it started happening with 1.29.2

tgodzik commented 2 months ago

Maybe you would be able to run this manually and get more error messages: curl -fL https://github.com/coursier/coursier/releases/download/v2.1.9/cs-x86_64-apple-darwin.gz | gzip -d > cs or alternatively use https://github.com/VirtusLab/coursier-m1/releases/download/v2.1.9/cs-aarch64-apple-darwin.gz for M1

smarkess commented 2 months ago
% curl -fL https://github.com/coursier/coursier/releases/download/v2.1.9/cs-x86_64-apple-darwin.gz | gzip -d > cs
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 19.2M  100 19.2M    0     0  15.4M      0  0:00:01  0:00:01 --:--:-- 29.3M
gzip: (stdin): trailing garbage ignored

So it's the same message minus the "failed to fetch" It seems like the issue isn't downloading but processing unpacked file.

My Mac is 12.4 which I can't update due to company policy

tgodzik commented 2 months ago

Maybe it's an issue with gzip version? Looks like the only way yo work around it is to fallback to use coursier.jar as previously, but that will only work if JAVA_HOME is set.

yadavan88 commented 2 months ago

I also have the same problem with VS Code on my Mac(14.4.1). I downgraded to 1.29.0 and it worked for me.

@tgodzik A request for a temporary situation: Is it possible to re-release with the working version as 1.31.0 so that newbies don't run into this problem? I doubt how many people will find this issue and downgrade to an earlier version for the fix. (I am having a meetup with live coding for Java people next week. They will be installing metals for first time. Everyone will need to explicitly downgrade the version. So, just thinking from that perspective)

Thanks

tgodzik commented 2 months ago

I wanted to fix one more thing, but you're right, we should do a new release with the current fixes. Will do it Sunday or Monday, sorry about that!

tgodzik commented 2 months ago

I release a new version, do let me know if it works.

yadavan88 commented 2 months ago

Thank you so much @tgodzik It works with the new update! :)

tgodzik commented 2 months ago

Glad to hear it!

smarkess commented 2 months ago

It still doesn't work for me, so I guess there's an issue with older mac version. It would be cool if there was some way to specify max version for an extension depending on operating system.

tgodzik commented 2 months ago

What is an error you are getting? I need to still do another workaround

smarkess commented 2 months ago

The exact same. Nothing changed for me.

yadavan88 commented 2 months ago

@smarkess did you already try uninstall the plugin and reinstall? Initially it didn't work for me as well. Then I uninstalled plugin and deleted metadata files. Then it worked for me . Thought it might be some coincidence and ignored it

smarkess commented 2 months ago

@yadavan88 Clean uninstall (with manually removing metadata files after uninstalling extension by UI) also didn't work

hhucchenyixiao commented 2 months ago

I am still encountering this issue using version 1.31.0.

tgodzik commented 2 months ago

@hhucchenyixiao the problem the same as in the description of the issue?

hhucchenyixiao commented 2 months ago

@hhucchenyixiao the problem the same as in the description of the issue? Yes, it's exactly as described in the issue, it shows "No Scala project found", and clicking either of the buttons does not elicit any response. 图片

tgodzik commented 2 months ago

Could you check Output (metals) if there is any info?

yadavan88 commented 2 months ago

@tgodzik @smarkess I am not sure, but now it is not working. I was pretty sure that it worked when I posted the message, but now when I try to use again, getting the same problem. My apologies

yadavan88 commented 2 months ago

@tgodzik Just one more update. Now I know why it worked. I have 2 mac books, it works fine in one, but not in the other.

Working mac: Macbook air - 12.7 (attaching the screenshot) Not working: Macbook Pro - 14.4

image

sjrd commented 2 months ago

Sorry for the radio silence. v1.31.0 works fine over here on Windows. Thank you :)

tgodzik commented 2 months ago

The fallback to the old way of fetching metals has been added back. Can anyone having issues let us know if that fixed something? You need to switch to newest prerelease.

yadavan88 commented 2 months ago

@tgodzik Still the same for me, in mac 14.4.1

image
tgodzik commented 2 months ago

@yadavan88 could you check Metals output to see what is being logged? View -> Output and choose Metals in the dropdown.

yadavan88 commented 2 months ago

Hi @tgodzik

Metals version: 1.3.0 Using coursier located at /Users/yadukrishnankrishnan/Library/Application Support/Coursier/bin/coursier /Users/yadukrishnankrishnan/Library/Caches/Coursier/arc/https/github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%252B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz/jdk-11.0.9.1+1/Contents/Home/bin/java -version: openjdk version "11.0.9.1" 2020-11-04 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1) /Users/yadukrishnankrishnan/Library/Caches/Coursier/arc/https/github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%252B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz/jdk-11.0.9.1+1/Contents/Home/bin/java -version: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode) Found java executable under /usr/bin/java that resolves to /usr/bin/java /usr/bin/java -version: openjdk version "11.0.9.1" 2020-11-04 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode) No installed java with version 17 found. Will fetch one using coursier. Coursier: JVM 17 not found in index: No adopt version matching '1.17+' found Error: Process exited with code 1 Release notes was not shown: not showing release notes since they've already been seen for your current version

After that when I click on "start metals", nothing logs

tgodzik commented 2 months ago

Looks like coursier is actually old and unable to resolve adopt as a default, which does not hava Java 17 indeed.

Does coursier java --jvm temurin:17 -version work for you?

yadavan88 commented 2 months ago

Yes, it does

image
tgodzik commented 2 months ago

ok, this should fix it then https://github.com/scalameta/metals-vscode/pull/1500

tgodzik commented 2 months ago

You should be able to try it out again.

smarkess commented 2 months ago

@tgodzik For 1.31.3 I get the following:

Metals version: 1.2.2
Fetching coursier
Coursier: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Coursier: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Coursier: 0     0    0     0    0     0      0      0
Coursier: --:--:-- --:--:-- --:--:--     0
Coursier: 81 19.2M   81 15.6M    0
Coursier: 0  12.8M      0  0:00:01  0:00:01 --:--:-- 12.8M
Coursier: 100 19.2M  100 19.2M    0     0  14.6M
Coursier: 0  0:00:01  0:00:01 --:--:-- 36.3M
Coursier: gzip: (stdin): trailing garbage ignored
Failed to fetch coursier. You may want to try installing coursier manually and adding it to PATH.
Will try to use jar based coursier if Java is available on the machine.
Using coursier located at undefined
/Library/Java/JavaVirtualMachines/corretto-11.0.14/Contents/Home/bin/java -version:
openjdk version "11.0.14" 2022-01-18 LTS
/Library/Java/JavaVirtualMachines/corretto-11.0.14/Contents/Home/bin/java -version:
OpenJDK Runtime Environment Corretto-11.0.14.9.1 (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.14.9.1 (build 11.0.14+9-LTS, mixed mode)
Found java executable under /usr/bin/java that resolves to /usr/bin/java
/usr/bin/java -version:
openjdk version "11.0.14" 2022-01-18 LTS
/usr/bin/java -version:
OpenJDK Runtime Environment Corretto-11.0.14.9.1 (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.14.9.1 (build 11.0.14+9-LTS, mixed mode)
Using Java Home: undefined
Error: Cannot resolve Java home or coursier, please provide at least JAVA_HOME.
Release notes was not shown: not showing release notes since they've already been seen for your current version

I have JAVA_HOME setup in both .zshrc and .bash_profile. Also, before (1.29.0) it didn't have problems finding JAVA_HOME. But at the very least it doesn't fail silently like before and instead shows error popup with JAVA_HOME message.

tgodzik commented 2 months ago

@smarkess you can change the version of Java required by Metals to be 11. We try to find 17 by default, which is why we are not picking up the local 11.

"metals.javaVersion": "11"
smarkess commented 2 months ago

@tgodzik Yup, that fixed it for me. 1.31.3 now works. Thanks!

yadavan88 commented 2 months ago

@tgodzik Still doesnt work for me. It is still failing with adopt 17 error

image
tgodzik commented 2 months ago

As a workaround you can try to update coursier. I will look into what is happening a bit later

yadavan88 commented 2 months ago

Thanks, it works fine after coursier update

tgodzik commented 2 months ago

I missed one place with my previous fix https://github.com/scalameta/metals-vscode/pull/1503