VSCode on Fedora: Sonarlint cannot find Java path

Hello, I’m using

  • VSCode 1.74.3 + Remote SSH extension version 0.94.0
  • Fedora 37 on UTM (VM on MacOS)
  • OpenJDK version 11

when I open VSCode, Sonarlint extension is activated; although I’ve my Java installed and running which java produce /usr/bin/java, the extension cannot find Java in my system. Additionally when I click on “Let Sonar download the JRE” nothing happens and the output from the extension lacks error info.

What am I missing?

PS I also tried to set the sonarlint.ls.javaHome, JAVA_HOME, with no luck

Hello, welcome to the community! And thanks for reporting this.

If I understand correctly, you are using the VSCode client on macOS, connecting through SSH to a remote workspace on the Fedora VM, did I get this right?

If this is the case, a Java 11 or 17 runtime has to be available on the remote - that is, on the VM - since this is where the Language Server will run.

Also, if you want to set the JVM’s location using the sonarlint.ls.javaHome property, it has to be set in the “Remote” settings.

Hello, thanks for replying. Yes you’re correct, my VSCode is running on Mac and connecting via SSH to a VM I created.

So I installed Java on my remote, I also set the sonarlint.ls.javaHome in the correct place but this has no effect and I always get “Couldn’t start client SonarLint Language Server”.

Any suggestion on how to solve the issue?

Hi is there any update on this?

Hello, thanks for pinging back on this thread.

I tried to reproduce your setup (macOS host + SSH remote on Fedora guest in UTM), but did not manage to end up with the same error.

What is the version of Java installed on the remote host? You should be able to get this information by running: java -version

Also, you can have a look at the SonarLint output tab and VSCode console (Help > Toggle Developer Tools) for additional details.

Unfortunately, since most of the extension’s code resides in the language server, there is not a lot that can be logged when it doesn’t start.

Hello, thanks for the reply.

These are my Java information

[danilo@fedora ~]$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (Red_Hat-17.0.6.0.10-1.fc37) (build 17.0.6+10)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.10-1.fc37) (build 17.0.6+10, mixed mode, sharing)

This is the output from the extension output tab

[Error - 15:33:58] Starting client failed
[object Object]

This is my console

log.ts:304  INFO [attempt 1] Invoking resolveAuthority(ssh-remote)
log.ts:316   ERR [Extension Host] (node:4613) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code Helper (Plugin) --trace-deprecation ...` to show where the warning was created)
console.ts:137 [Extension Host] (node:4613) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code Helper (Plugin) --trace-deprecation ...` to show where the warning was created)
E @ console.ts:137
log.ts:304  INFO [attempt 1] resolveAuthority(ssh-remote) returned '127.0.0.1:57965' after 905 ms
notificationsAlerts.ts:42 The Java Runtime Environment can not be located. Please install a JRE, or configure its path with the       sonarlint.ls.javaHome property. You can also let SonarLint download the JRE from AdoptOpenJDK. This JRE will be       used only by SonarLint.
c @ notificationsAlerts.ts:42
notificationsAlerts.ts:42 Couldn't start client SonarLint Language Server
c @ notificationsAlerts.ts:42
log.ts:304  INFO [perf] Render performance baseline is 15ms
console.ts:137 [Extension Host] rejected promise not handled within 1 second: [object Object]
E @ console.ts:137
log.ts:316   ERR The Java Runtime Environment can not be located. Please install a JRE, or configure its path with the
      sonarlint.ls.javaHome property. You can also let SonarLint download the JRE from AdoptOpenJDK. This JRE will be
      used only by SonarLint.
console.ts:137 [Extension Host] rejected promise not handled within 1 second: [object Object]
E @ console.ts:137

Please let me know if I can provide any other information. Could you elaborate how did you installed the extension, and java?

Thanks

When you tried to set sonarlint.ls.javaHome, which value did you set it to?

As far as I can tell, if which java returns /usr/bin/java, it means that it is most probably a file system link.

In order to know the actual value to use in sonarlint.ls.javaHome, you can run the following command (on the remote): readlink -f /usr/bin/java | sed "s:bin/java::"

For reference, on my (Ubuntu) development box with OpenJDK 11, it returns /usr/lib/jvm/java-11-openjdk-amd64/.

I did as you suggested but the extension keeps not finding Java…

I suppose your function readJavaConfig from requirements.ts in /src/utils (SonarLint git repo) returns a null string in my case… and I’m not sure why though…

Hello,

In your screenshot, I see that you added the sonarlint.ls.javaHome property in your user settings on the macOS host, not on the Fedora remote.

You have to set it in the remote settings, which should be in file ${HOME}/.vscode-server/data/Machine/settings.json on the Fedora remote.

Wow! Thanks for that now it seems working :slight_smile: Worth to add it to the doc IMO :stuck_out_tongue:

Thanks again
Dani

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.