Windows 10 Enterprise x64
Microsoft Visual Studio Professional 2022 (Version 17.12.1, VisualStudio.17.Release/17.12.1+35514.174)
SonarLint for Visual Studio 2022: 8.6.0.10679
Coding in C++
Attempting to connect to SonarQube v10.5.1 (90531)
I want to connect Visual Studio to my SonarQube server via SonarLint and bind to my project.
In the Manage Project Binding dialog click Manage Connections to add a connection.
New connection: SonarQube Server
URL: https://path_to_corporate_server/sonarqube/
Next
Authentication type: token
Paste in user type token copied from security page on the SQ server.
When I click OK I get this at the bottom of the dialog:
and the SonarLint output window in VS says: [SharedBindingConfigProvider] SonarLint shared folder was not found
My Bindings folder is at C:\Users<user_name>\AppData\Roaming\SonarLint for Visual Studio\Bindings but it’s empty.
Reinstalling the SonarLint plugin doesn’t fix this.
Thanks Ann. I set SonarLint to use verbose logging, cleared the logs and then repeated the sequence of steps above.
[ThreadId 1] [SharedBindingConfigProvider] SonarLint shared folder was not found
[ThreadId 73] [DEBUG] [SLCORE] Request failed
[ThreadId 73] [DEBUG] [SLCORE] GET https://path_to_corporate_server/sonarqube/api/system/status java.net.UnknownHostException: No such host is known (path_to_corporate_server) | failed after 125ms
I replaced the corporate server’s domain name with path_to_corporate_server in the logs.
Yes, a curl request to the same GET URL works fine from a git bash prompt:
$ curl https://path_to_corporate_server/sonarqube/api/system/status
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 77 0 77 0 0 118 0 --:--:-- --:--:-- --:--:-- 119{"id":"blah_blah","version":"10.5.1.90531","status":"UP"}
Thanks. I’m afraid you’ve got all those already. I just went through the process again to get the verbose logs:
[ThreadId 1] [SharedBindingConfigProvider] The .sonarlint shared folder was not found
[ThreadId 113] [DEBUG] [SLCORE] Request failed
[ThreadId 113] [DEBUG] [SLCORE] GET https://server_name_redacted/api/system/status java.net.UnknownHostException: No such host is known (server_name_redacted) | failed after 54ms
[ThreadId 1] [SharedBindingConfigProvider] The .sonarlint shared folder was not found
Unfortunately the JRE is installed by corporate IT and is no later than 1.8. I found C:\Program Files (x86)\Java\jre1.8.0_431\lib\net.properties and changed java.net.useSystemProxies=true (I needed admin privileges to do this). I also set the path to Java Home in SonarLint’s settings as C:\Program Files (x86)\Java\jre1.8.0_431\bin. And updated SonarLint to 8.8.0.11278. None of this made any difference to the original error (java.net.UnknownHostException in the verbose logs). I see you require JRE 17+ but we can’t install that in our corporate environment.
Aside: This is getting horribly messy just for connecting SonarLint to a SQ server; not a good user experience IMO:(. Especially when it’s much easier for installing SonarLint in PyCharm and VSCode. Most of my colleagues have next to no experience with Java, so asking them to do all this won’t be popular at all. Why can’t the default JRE used by SonarLint simply pick up the system’s or user’s proxy settings instead? That a JRE is involved should be invisible to the end-user.
The path to JRE should not point to the bin folder, but to the root folder. You should have a log entry similar to:
[DEBUG] Unable to detect java installation provided in the settings “C:\Program Files (x86)\Java\jre1.8.0_431\bin\bin\java.exe”. Embedded JRE will be used.
We do need indeed JRE 17+.
I created this custom build that picks up the system proxies. I would invite you to install it and see if you are still facing this problem. If you do, please share the verbose logs with us.
Thanks @gabriela.trutan. I’ve fixed the path to the JRE. I now see this in the verbose logs:
[ThreadId 112] [SLCORE-ERR] Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonarsource/sonarlint/core/backend/cli/SonarLintServerCli has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
…which I presume is due to running JRE < 17. However the software we can install on our corporate PCs is locked down and it seems we’re not allowed to install a JRE > 8. Hopefully I can try installing a more recent JDK version tomorrow. Then I can try your custom build.
@gabriela.trutan - apologies, it turns out I did have a JDK > 17 installed in my system after all. But setting the path to the JDK didn’t fix the problem (although that UnsupportedClassVersionError is now gone). Nor did setting java.net.useSystemProxies=true in C:\Tools\jdk\jdk-20.0.1\conf\net.properties fix it.
So I installed your custom build by closing Visual Studio and running your vsix file. It reported a successful installation. However when I try to add the binding to the SQ server in VS I see nothing different in the verbose logs: nothing to do with proxies; and I still get the same old GET request error: java.net.UnknownHostException: No such host is known...
Should I have uninstalled the original SonarLint extension before installing your vsix file? How do I confirm in the logs that your extension is installed correctly? Please let me know if there are any special install instructions that need following.
I have tried the experimental build. Using openjdk 23. I have set -Djava.net.useSystemProxies=true in my environment settings and in net.properties.
No luck.
The VSCODE extension for SonarLint works. It seems that something is broken in the extension for VS2022.
Some bits from the verbose log that could be of interest;:
[ThreadId 8] [SLCORE-ERR] Picked up JAVA_TOOL_OPTIONS: -Djava.net.useSystemProxies=true
[ThreadId 42] [SLCORE-ERR] Picked up _JAVA_OPTIONS: -Djava.net.useSystemProxies=true
.
.
.
[ThreadId 141] [DEBUG] [SLCORE] Request failed
[ThreadId 141] [DEBUG] [SLCORE] GET https://sonarcloud.io/api/system/status org.apache.hc.client5.http.HttpHostConnectException: Connect to https://sonarcloud.io:443 [sonarcloud.io/18.66.147.93, sonarcloud.io/18.66.147.51, sonarcloud.io/18.66.147.13, sonarcloud.io/18.66.147.49] failed: Connection timed out: getsockopt | failed after 86679ms
[ThreadId 141] [SLCORE] Error during synchronization
It looks like some of the requests are getting through and working but not all.
What seems to timeout is when I want to set up the connected mode.
I already have a json with SonarCloudOrganization and ProjectKey in the repo. But if I open the bind to option in the gui, that times out.
I subsequently uninstalled the SonarQube for Visual Studio extension and reinstalled it from your vsix file. Still no difference to the error reported when I try to bind to the SQ server and nothing in the verbose logs about proxies.
Update after reading @Michael_Sendow 's post above: no mentions of JAVA_TOOL_OPTIONS or JAVA_OPTIONS in the verbose logs either! Note my GET error (java.net.UnknownHostException) is different to his, and he’s trying to connect to SonarCloud whereas I’m trying to connect to a SQ server.
Hello @Michael_Sendow and welcome to Sonar Community!
Thank you for the very detailed feedback. Could you send us the verbose logs or, at least, let us know which of the requests are getting through?
@cacti77, thank you for trying the custom build. We are currently working on an alternative solution.