usethesource / rascal-language-servers

An LSP server for Rascal which includes an easy-to-use LSP generator for languages implemented in Rascal, and an interactive terminal REPL.
BSD 2-Clause "Simplified" License
10 stars 7 forks source link

VS Code extension gets confused if default Java version is set incorrectly #332

Closed linuswagner closed 9 months ago

linuswagner commented 9 months ago

We were on a system running OpenJDK 8 and 11. OpenJDK 8 was set as the default.

When you install the VS Code extension in this context, it does not prompt you with the dialog if you want to install a JDK.

However, the REPL fails to load, because it tries the default version of the JDK (here: 8) and his is below the supported version of Rascal.

Either, the plugin should notify the user of this problem and help to change the default or Rascal itself should not go for the system default, but for the JDK that it supports.

DavyLandman commented 9 months ago

Hmm that is strange. It should find the jdk 11 and run with that, or else show a warning message.

Could you provide a bit of context? Which OS? What is JAVA_HOME?

Also, please share the specific javac -version output, maybe the regex is firing on something in there that it shouldn't.

linuswagner commented 9 months ago

Sadly, I do not have the student with me anymore. But the OS was Ubuntu 22 and the output of java -version is

openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-8u342-b07-1-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)

javac -version then gives javac 1.8.0_342.

I don't know what JAVA_HOME pointed to

DavyLandman commented 9 months ago

Strange, that should not have been allowed, as the regex detects that javac 1.8.0_342 as jdk8.

DavyLandman commented 9 months ago

I just tested it out on a fresh install of windows, installed java 8, and on first start of a REPL (or any other rascal action), I get this popup:

image

after that, it installs the local version of java and it works. maybe it's different on ubuntu?

linuswagner commented 9 months ago

Thanks for the effort! I'll set up an Ubuntu VM next week and try my best to reproduce the issue for you.

linuswagner commented 9 months ago

I checked it again:

  1. Installed Ubuntu 22.04 with OpenJDK 8 and 11
  2. Using sudo update-java-alternatives --set /path/to/java/version I set Java 8 to the default
  3. Rascal doesn't run and VS Code prompts again to install the right version

Therefore, bug not confirmed. However, I found that VS Code does not prompt during a single session again if you click the message away. Only, if you close and re-open VS Code, the popup comes again. Maybe, we ran into this (even though, we did several restarts)

jurgenvinju commented 9 months ago

Thanks @linuswagner for reporting and the thoughtful analysis. Cheers!

DavyLandman commented 9 months ago

However, I found that VS Code does not prompt during a single session again if you click the message away. Only, if you close and re-open VS Code, the popup comes again.

this is by design, to not bother the user too much. but then again, stuff isn't working as they would expect (as in there is no rascal). So maybe we should reconsider this.

But like Jurgen said, thanks for verifying.