SonarLint extension for VS Code hanging in VS Code 1.55.2

  • SonarQube - 8.8.0.42792 Developer
  • SonarLint - v1.21.0
  • VS Code - Version: 1.55.2 (Universal)
  • Java - openjdk 11.0.10 2021-01-19
  • macOS 11.2.1

When I installed the plugin, I am not getting any logs (nothing in SonarLing.log), output, problems, etc. The Sonarlint rules dropdown hangs and looks like it is trying to connect but never logs anything. I also noticed that when trying to update project bindings I get the following error:

Command ‘SonarLint: Update all project bindings to SonarQube/SonarCloud’ resulted in an error (command ‘SonarLint.UpdateAllBindings’ not found)

The only log I can find is from the extension host:

[2021-04-20 14:29:58.877] [exthost] [info] ExtensionService#_doActivateExtension SonarSource.sonarlint-vscode {“startup”:false,“extensionId”:{“value”:“SonarSource.sonarlint-vscode”,"_lower":“sonarsource.sonarlint-vscode”},“activationEvent”:“onLanguage:python”}

My VS Code config:

    {
        "workbench.colorTheme": "Noctis Lux",
        "editor.renderWhitespace": "all", 
        "sonarlint.connectedMode.connections.sonarqube": [
            {
                "serverUrl": "https://my.sonar.instance",
                "token": "myTokenXXXX"
              }
        ],
        "workbench.editorAssociations": [
            {
                "viewType": "jupyter.notebook.ipynb",
                "filenamePattern": "*.ipynb"
            }
        ],
        "sonarlint.disableTelemetry": true,
        "sonarlint.connectedMode.project": {
            "projectKey": "my_project_key"
        },
        "sonarlint.output.showAnalyzerLogs": true
    }

Hello, thank you for reporting this issue.

It seems that the extension is failing to activate for some reason.

I notice from your extract of the extension host log that the extension does seem to receive an activation event when opening a Python file, at which point it should spawn a Java process for the Language Server.

Could you please do the following:

  • Put the following settings in your VSCode config
{
  "sonarlint.output.showAnalyzerLogs": true,
  "sonarlint.output.showVerboseLogs": true,
  "sonarlint.trace.server": "verbose"
}
  • Close all open editors, exit and restart VSCode
  • Open the developer tools - “Help” > “Toggle Developer Tools”
  • Select a Python file

At this point, any error thrown during the extension activation should be visible in the console. You can check whether the Language Server is started by executing the following command in a terminal (provided that the JAVA_HOME environment variable points to your OpenJDK 11 installation directory):

$ ${JAVA_HOME}/bin/jps

One of the lines output by jps should read sonarlint-ls.jar.

If this is not the case, maybe the extension is having trouble finding the right path to the JRE, in which case you can specify it with the sonarlint.ls.javaHome property.

Also, please note that the "sonarlint.trace.server": "verbose" property can result in a log of content in the SonarLint Output, so I would advise that you set it to "off" once SonarLint is back on its feet.

After some investigation, I found that the install of Java I had (from Brew) was not working with the plugin. I uninstalled that Brew installation and when I reinstalled the plugin, I followed the links to install a version of Java and things started to work. The only thing that I cannot figure out is why the Sonarlint Issue Locations is always empty.

1 Like

Hello, thank you for the heads-up! I’m glad that you found a solution to your initial issue.

As stated in the empty state message, the “SonarLint Issue Locations” view is meant to show additional locations for some of the issues detected by SonarLint.

Capture d’écran de 2021-04-28 15-15-36

You’ll want to look for the “Show all locations…” code action on relevant issues:

All issues raised by SonarLint will be visible in the “Problems” view, and highlighted in code editor tabs according to their level.