Sonarlint issue when using Windows, WSL2 and symlinks

  • versions used: Sonarlint for VS Code v3.2.0
  • error observed
[stderr] SEVERE: Internal error: java.lang.IllegalStateException: Unable to list files in directory z:\myuser\myapp

full log later

  • steps to reproduce
    We are doing some Magento development (php)
    We have a Windows OS with WSL2 running Debian
    In the WSL we setup our dev env which pulls our code from github, the folder the code is pulled into is also where the Magento instance runs from (which is done using Docker)
    The important thing to reproduce is the folder we point VS Code are it is the code from git plus other sub folders that are populated by the build of Magento. This build process creates some symlinks, the symlinks are in folders not under source control but are needed to run the dev env).
    Our .gitignore file ignores these folders (though it works by excluding everything and listed what shouldn’t be ignored)
    We develop by running VS Code in Windows but by pointing it at a folder in WSL filesystem
    e.g. \wsl$\Debian\myuser\myapp
    The sonarlint extension wasn’t happy with such filepaths, but if we map a windows drive letter to \wsl$\Debian it is happy enough to start reading files
    When it tries to open a file that is a symlink in WSL it crashes (full log later) which is valid as trying to open the linux symlink file in anything in Windows will crash.
    From reading How to exclude folders from sonarlint scan I see there is no way explicitly tell the sonarlint extension of folders that it should exclude
    What I want to do tell Sonarlint to exclude the folders that have symlinks in them
    I have tried
  • Explicitly adding the folders to ignore to the .gitignore file
  • Updating a sonar-project.properties file in the root of the folder tree to have sonar.exclusions to exclude the folders
  • We are pointing Sonarlint at Sonarcloud so i tried setting sonar.exclusions in SonarCloud for the relevant project
    In all cases Sonarlint tried to open a symlink in the folders I was trying to exclude
  • potential workaround
    Not known

log with verbose turned on

Executing C:\Program Files\Java\jdk-16.0.1\bin\java -jar c:\Users\bonner.earle\.vscode\extensions\sonarsource.sonarlint-vscode-3.2.0\server\sonarlint-ls.jar 55531 -analyzers file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarjava.jar file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarjs.jar file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarphp.jar file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarpython.jar file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarhtml.jar -extraAnalyzers file:///c:/Users/bonner.earle/.vscode/extensions/sonarsource.sonarlint-vscode-3.2.0/analyzers/sonarsecrets.jar
[stdout] Binding to 55531
Child process connected on port 55531
[stderr] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[stderr] SLF4J: Defaulting to no-operation (NOP) logger implementation
[stderr] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[Info  - 18:00:45.102] Started security hotspot handler on port 64121
Initializing file:///z%3A/myuser/myapp on branch 4734_GetLatestVersionOfSamlPlugin
[Debug - 18:00:45.158] Execute command 'C:\Windows\System32\where.exe $PATH:node.exe'...
[Debug - 18:00:45.183] Enabling notifications for project '288-Group_magento' on connection '<default>'
[Debug - 18:00:45.185] Default settings updated: WorkspaceFolderSettings[analyzerProperties={},connectionId=<default>,projectKey=288-Group_magento,testFilePattern=]
[Debug - 18:00:45.250] Command 'C:\Windows\System32\where.exe $PATH:node.exe' exited with 1
stderr: INFO: Could not find files for the given pattern(s).
[Debug - 18:00:45.250] Unable to locate node
[Debug - 18:00:45.337] Create : C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:45.337] Plugin cache: C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:45.338] Create : C:\Users\bonner.earle\.sonarlint\plugins\_tmp
[Debug - 18:00:45.364] Load plugins
[Debug - 18:00:45.409] Plugin 'JavaScript/TypeScript Code Quality and Security' requires Node.js 10.12.0. Skip loading it.
[Debug - 18:00:45.431] Load plugins (done) | time=67ms
[Debug - 18:00:45.511] Plugins:
[Debug - 18:00:45.511]   * License for SonarLint 8.0.0.26500 (license)
[Debug - 18:00:45.512]   * Python Code Quality and Security 3.9.0.9230 (python)
[Debug - 18:00:45.512]   * Java Code Quality and Security 7.8.0.28662 (java)
[Debug - 18:00:45.512]   * HTML Code Quality and Security 3.6.0.3106 (web)
[Debug - 18:00:45.512]   * PHP Code Quality and Security 3.22.1.8626 (php)
[Debug - 18:00:45.512]   * Apex Code Quality and Security 1.9.0.3429 (sonarapex)
[Debug - 18:00:45.512]   * Sonar Secrets Plugin for SonarQube 1.1.0.36766 (secrets)
[Debug - 18:00:45.512]   * PL/SQL Code Quality and Security 3.7.0.4372 (plsql)
[Info  - 18:00:45.609] Using storage for connection '<default>' (last update 02/02/2022, 17:42)
[Info  - 18:00:45.709] Creating container for module with key=file:///z:/myuser/myapp
[Debug - 18:00:45.717] SonarLint engine started for connection '<default>'
[Debug - 18:00:55.015] Checking binding updates
[Debug - 18:00:55.035] Create : C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:55.035] Plugin cache: C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:55.036] Create : C:\Users\bonner.earle\.sonarlint\plugins\_tmp
[Debug - 18:00:55.377] GET 200 https://sonarcloud.io/api/settings/values.protobuf | response time=51ms
[Info  - 18:00:55.384] Downloaded settings in 58ms
[Debug - 18:00:55.427] GET 200 https://sonarcloud.io/api/plugins/installed | response time=35ms
[Info  - 18:00:55.430] Downloaded plugin list in 38ms
[Debug - 18:00:55.433] Code analyzer 'abap' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.434] Code analyzer 'csharp' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.434] Code analyzer 'cpp' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'cobol' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'config' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'flex' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'go' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'iac' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'jacoco' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.435] Code analyzer 'kotlin' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'scmmercurial' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'ruby' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'sonarscala' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'swift' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'tsql' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'text' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'vbnet' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.436] Code analyzer 'security' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'securitycsharpfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'securityjsfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'securityjavafrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'securityphpfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'securitypythonfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.437] Code analyzer 'xml' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.507] GET 200 https://sonarcloud.io/api/qualityprofiles/search.protobuf?organization=288group-php | response time=67ms
[Debug - 18:00:55.513] Downloaded quality profiles in 73ms
[Debug - 18:00:55.597] GET 200 https://sonarcloud.io/api/qualityprofiles/search.protobuf?project=288-Group_magento&organization=288group-php | response time=71ms
[Debug - 18:00:55.598] Downloaded project quality profiles in 72ms
[Debug - 18:00:55.651] GET 200 https://sonarcloud.io/api/settings/values.protobuf?component=288-Group_magento | response time=52ms
[Info  - 18:00:55.651] Downloaded settings in 52ms
[Debug - 18:00:55.701] Page downloaded in 43ms
[Debug - 18:00:55.707] Create : C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:55.707] Plugin cache: C:\Users\bonner.earle\.sonarlint\plugins
[Debug - 18:00:55.708] Create : C:\Users\bonner.earle\.sonarlint\plugins\_tmp
[Debug - 18:00:55.788] GET 200 https://sonarcloud.io/api/settings/values.protobuf | response time=40ms
[Info  - 18:00:55.789] Downloaded settings in 40ms
[Debug - 18:00:55.820] GET 200 https://sonarcloud.io/api/plugins/installed | response time=31ms
[Info  - 18:00:55.822] Downloaded plugin list in 32ms
[Debug - 18:00:55.822] Code analyzer 'abap' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'csharp' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'cpp' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'cobol' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'config' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'flex' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'go' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'iac' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'jacoco' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.823] Code analyzer 'kotlin' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'scmmercurial' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'ruby' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'sonarscala' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'swift' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'tsql' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.824] Code analyzer 'text' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'vbnet' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'security' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'securitycsharpfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'securityjsfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'securityjavafrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'securityphpfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.825] Code analyzer 'securitypythonfrontend' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.826] Code analyzer 'xml' is not compatible with SonarLint. Skip downloading it.
[Debug - 18:00:55.914] GET 200 https://sonarcloud.io/api/qualityprofiles/search.protobuf?organization=288group-php | response time=88ms
[Debug - 18:00:55.915] Downloaded quality profiles in 89ms
[Debug - 18:00:56.048] GET 200 https://sonarcloud.io/api/qualityprofiles/search.protobuf?project=288-Group_magento&organization=288group-php | response time=128ms
[Debug - 18:00:56.049] Downloaded project quality profiles in 129ms
[Debug - 18:00:56.090] GET 200 https://sonarcloud.io/api/settings/values.protobuf?component=288-Group_magento | response time=41ms
[Info  - 18:00:56.091] Downloaded settings in 42ms
[Debug - 18:00:56.126] Page downloaded in 35ms
[Debug - 18:00:57.435] Queuing analysis of file 'file:///z:/myuser/myapp/.magento.app.yaml'
[Debug - 18:00:57.640] Cached SCM ignore status for file 'file:///z:/myuser/myapp/.magento.app.yaml'
[Debug - 18:01:17.675] Queuing analysis of file 'file:///z:/myuser/myapp/app/code/Two88Group/WebGeneral/Plugin/AddressDeleteInterceptor.php'
[Debug - 18:01:45.048] GET 200 https://sonarcloud.io/api/developers/search_events?projects=288-Group_magento&from=2022-02-02T18%3A01%3A45%2B0000 | response time=34ms
[stderr] Feb 02, 2022 6:02:27 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
[stderr] SEVERE: Internal error: java.lang.IllegalStateException: Unable to list files in directory z:\myuser\myapp
[stderr] java.util.concurrent.CompletionException: java.lang.IllegalStateException: Unable to list files in directory z:\myuser\myapp
[stderr] 	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
[stderr] 	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
[stderr] 	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
[stderr] 	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
[stderr] 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
[stderr] 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
[stderr] 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
[stderr] 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
[stderr] 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[stderr] Caused by: java.lang.IllegalStateException: Unable to list files in directory z:\myuser\myapp
[stderr] 	at org.sonarsource.sonarlint.core.client.api.util.FileUtils.allRelativePathsForFilesInTree(FileUtils.java:194)
[stderr] 	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.computeProjectBinding(ProjectBindingManager.java:219)
[stderr] 	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$getBinding$0(ProjectBindingManager.java:156)
[stderr] 	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
[stderr] 	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getBinding(ProjectBindingManager.java:149)
[stderr] 	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getBinding(ProjectBindingManager.java:144)
[stderr] 	at org.sonarsource.sonarlint.ls.CommandManager.computeCodeActions(CommandManager.java:110)
[stderr] 	at org.sonarsource.sonarlint.ls.SonarLintLanguageServer.lambda$codeAction$3(SonarLintLanguageServer.java:275)
[stderr] 	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
[stderr] 	... 6 more
[stderr] Caused by: java.nio.file.FileSystemException: z:\myuser\myapp\pub\static\adminhtml\Magento\backend\en_GB\Magezon_PageBuilderPreview\css\builder.css: Incorrect function
[stderr] 	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
[stderr] 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
[stderr] 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
[stderr] 	at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
[stderr] 	at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
[stderr] 	at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:199)
[stderr] 	at java.base/java.nio.file.Files.readAttributes(Files.java:1843)
[stderr] 	at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
[stderr] 	at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
[stderr] 	at java.base/java.nio.file.FileTreeWalker.next(FileTreeWalker.java:373)
[stderr] 	at java.base/java.nio.file.Files.walkFileTree(Files.java:2840)
[stderr] 	at java.base/java.nio.file.Files.walkFileTree(Files.java:2876)
[stderr] 	at org.sonarsource.sonarlint.core.client.api.util.FileUtils.allRelativePathsForFilesInTree(FileUtils.java:170)
[stderr] 	... 14 more

An update.
The error it is throwing doesn’t stop it eventually scanning files. It just takes it an hour and a half before it starts working, and the errors trying to read the first symlink files stop occurring, hence why I thought it was broken.
Our workspace does contains lots of files (150,000ish), most of which are in folders I want to exclude from Sonarlint.

Hello @bonner-earle and welcome to the community.

Sorry for the late answer.
Thank you for your detailed report. We currently indeed do not support WSL provided node.js.
Looks like your workaround with mapping the WSL file system as network drive throws an exception because of this bug somewhere between JDK and Windows.
I’ve created the ticket for your request, but I’m not sure it will be implemented soon. If you want to increase visibility of this request, I suggest you to create topic in Suggest new features section of this forum and vote for it.

UPD: The thing could be done on our side - we can ignore directories we can’t read. Ticket has been updated to reflect that.

Hi, we since have switched our IDE to PhpStorm (though not because of this) so this is no longer a problem for us. Thank you for looking into it.

1 Like