SonarLint w/ VS Code crashes on folder even when that file is not in source

Please provide

  • Operating system: Linux via WSL2
  • SonarLint plugin version: v3.22.0
  • Programming language you’re coding in: C++
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): SonarCloud Paid Plan

And a thorough description of the problem / question:

Java is throwing an exception while it enumerates files under our project directory:

java.lang.IllegalStateException: Unable to list files in directory /home/abond/src/torreys_peak

caused by…

java.nio.file.AccessDeniedException: /home/abond/src/torreys_peak/torreys/zc702/build/release_0.2.0/root/var/lib/sudo

Our build output has files that require super user privileges to open. But the release folder is not specified under our project sonar.sources.

I’ve tried adding exclusions through the VS Code File Exclusion setting, and through the sonar-project.properties file, but it doesn’t seem to matter – the engine wants to enumerate over all files even if they shouldn’t be analyzed.

Can you help? Thanks.

Hi @abond,

I assume you are opening VSCode in WSL mode?

I expect that the analyzer will need to access those directories especially if they contain header files.

Can you provide the full logs? It can help learn which part exactly requires access to that directory.

If you prefer to share them privately, I can send you a PM.

Thanks,

1 Like

Thanks for the reply. The directory I mentioned is created in a post-build process that combines our kernel with our application – it doesn’t contain any headers that our source code needs to build. In fact, if I delete that directory everything works fine.

Here are some of the logs, if you want more information let me know.

[Info  - 13:19:32.199] [SYNC] Synchronizing analyzer configuration for project 'PMSfirmware_torreys_peak1'
[Debug - 13:19:32.357] GET 200 https://sonarcloud.io/api/settings/values.protobuf?component=PMSfirmware_torreys_peak1 | response time=157ms
[Info  - 13:19:32.357] Downloaded settings in 157ms
[Debug - 13:19:32.548] GET 200 https://sonarcloud.io/api/qualityprofiles/search.protobuf?project=PMSfirmware_torreys_peak1&organization=pmsfirmware | response time=190ms
[Debug - 13:19:32.548] Downloaded project quality profiles in 191ms
[Info  - 13:19:32.548] [SYNC] Fetching rule set for language 'apex' from profile 'AYc0qhweZZXoAw3SbcTw'
[Debug - 13:19:32.719] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcTw&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=170ms
[Debug - 13:19:32.719] Page downloaded in 170ms
[Info  - 13:19:32.719] [SYNC] Fetching rule set for language 'c' from profile 'AYc0qhweZZXoAw3SbcUD'
[Debug - 13:19:32.912] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcUD&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=193ms
[Debug - 13:19:32.913] Page downloaded in 193ms
[Info  - 13:19:32.913] [SYNC] Fetching rule set for language 'cloudformation' from profile 'AYc0qhweZZXoAw3SbcUF'
[Debug - 13:19:33.073] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcUF&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=159ms
[Debug - 13:19:33.073] Page downloaded in 159ms
[Info  - 13:19:33.073] [SYNC] Fetching rule set for language 'cobol' from profile 'AYc0qhweZZXoAw3SbcTs'
[Debug - 13:19:33.244] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcTs&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=171ms
[Debug - 13:19:33.244] Page downloaded in 171ms
[Info  - 13:19:33.245] [SYNC] Fetching rule set for language 'cpp' from profile 'AYn6Yp4QPRityZJIF-HW'
[Debug - 13:19:33.461] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYn6Yp4QPRityZJIF-HW&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=216ms
[Debug - 13:19:33.462] Page downloaded in 217ms
[Info  - 13:19:33.462] [SYNC] Fetching rule set for language 'css' from profile 'AYc0qhweZZXoAw3SbcT1'
[Debug - 13:19:33.700] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcT1&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=238ms
[Debug - 13:19:33.700] Page downloaded in 238ms
[Info  - 13:19:33.700] [SYNC] Fetching rule set for language 'docker' from profile 'AYc0qhwfZZXoAw3SbcUI'
[Debug - 13:19:33.886] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUI&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=185ms
[Debug - 13:19:33.886] Page downloaded in 185ms
[Info  - 13:19:33.886] [SYNC] Fetching rule set for language 'go' from profile 'AYc0qhweZZXoAw3SbcUA'
[Debug - 13:19:34.053] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcUA&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=166ms
[Debug - 13:19:34.053] Page downloaded in 167ms
[Info  - 13:19:34.053] [SYNC] Fetching rule set for language 'java' from profile 'AYc0qhwfZZXoAw3SbcUK'
[Debug - 13:19:34.312] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUK&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=258ms
[Debug - 13:19:34.312] Page downloaded in 258ms
[Debug - 13:19:34.503] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUK&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=2 | response time=190ms
[Debug - 13:19:34.504] Page downloaded in 191ms
[Info  - 13:19:34.504] [SYNC] Fetching rule set for language 'js' from profile 'AYc0qhwfZZXoAw3SbcUJ'
[Debug - 13:19:34.719] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUJ&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=215ms
[Debug - 13:19:34.720] Page downloaded in 216ms
[Info  - 13:19:34.720] [SYNC] Fetching rule set for language 'kubernetes' from profile 'AYc0qhwfZZXoAw3SbcUH'
[Debug - 13:19:34.879] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUH&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=158ms
[Debug - 13:19:34.879] Page downloaded in 158ms
[Info  - 13:19:34.879] [SYNC] Fetching rule set for language 'php' from profile 'AYc0qhweZZXoAw3SbcUC'
[Debug - 13:19:35.073] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcUC&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=193ms
[Debug - 13:19:35.074] Page downloaded in 195ms
[Info  - 13:19:35.074] [SYNC] Fetching rule set for language 'plsql' from profile 'AYc0qhweZZXoAw3SbcTz'
[Debug - 13:19:35.258] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcTz&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=183ms
[Debug - 13:19:35.258] Page downloaded in 184ms
[Info  - 13:19:35.259] [SYNC] Fetching rule set for language 'py' from profile 'AYc0qhwfZZXoAw3SbcUL'
[Debug - 13:19:35.614] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUL&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=354ms
[Debug - 13:19:35.614] Page downloaded in 355ms
[Info  - 13:19:35.614] [SYNC] Fetching rule set for language 'secrets' from profile 'AYc0qhweZZXoAw3SbcT0'
[Debug - 13:19:35.797] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcT0&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=183ms
[Debug - 13:19:35.798] Page downloaded in 183ms
[Info  - 13:19:35.798] [SYNC] Fetching rule set for language 'terraform' from profile 'AYc0qhweZZXoAw3SbcUB'
[Debug - 13:19:35.973] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcUB&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=175ms
[Debug - 13:19:35.974] Page downloaded in 175ms
[Info  - 13:19:35.974] [SYNC] Fetching rule set for language 'ts' from profile 'AYc0qhwfZZXoAw3SbcUN'
[Debug - 13:19:36.185] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhwfZZXoAw3SbcUN&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=211ms
[Debug - 13:19:36.186] Page downloaded in 212ms
[Info  - 13:19:36.186] [SYNC] Fetching rule set for language 'web' from profile 'AYc0qhweZZXoAw3SbcT3'
[Debug - 13:19:36.348] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcT3&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=162ms
[Debug - 13:19:36.348] Page downloaded in 162ms
[Info  - 13:19:36.348] [SYNC] Fetching rule set for language 'xml' from profile 'AYc0qhweZZXoAw3SbcTu'
[Debug - 13:19:36.514] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcTu&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=165ms
[Debug - 13:19:36.514] Page downloaded in 165ms
[Info  - 13:19:36.514] [SYNC] Fetching rule set for language 'yaml' from profile 'AYc0qhweZZXoAw3SbcT_'
[Debug - 13:19:36.663] GET 200 https://sonarcloud.io/api/rules/search.protobuf?qprofile=AYc0qhweZZXoAw3SbcT_&organization=pmsfirmware&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY,SECURITY_HOTSPOT&s=key&ps=500&p=1 | response time=149ms
[Debug - 13:19:36.663] Page downloaded in 149ms
[Debug - 13:19:36.664] Storing project analyzer configuration in /home/abond/.sonarlint/storage/706d736669726d77617265/projects/504d536669726d776172655f746f72726579735f7065616b31/analyzer_config.pb
[Info  - 13:19:36.665] [SYNC] Synchronizing project branches for project 'PMSfirmware_torreys_peak1'
[Debug - 13:19:36.848] GET 200 https://sonarcloud.io/api/project_branches/list.protobuf?project=PMSfirmware_torreys_peak1 | response time=182ms
[Debug - 13:19:36.848] Storing project branches in /home/abond/.sonarlint/storage/706d736669726d77617265/projects/504d536669726d776172655f746f72726579735f7065616b31/project_branches.pb
[Debug - 13:19:36.988] GET 200 https://sonarcloud.io/api/measures/component.protobuf?additionalFields=periods&metricKeys=projects&component=PMSfirmware_torreys_peak1 | response time=139ms
[Debug - 13:19:36.988] Storing new code definition in /home/abond/.sonarlint/storage/706d736669726d77617265/projects/504d536669726d776172655f746f72726579735f7065616b31/new_code_definition.pb
[Debug - 13:19:36.989] Incremental issue sync is not supported. Skipping.
[Debug - 13:19:36.989] Incremental taint issue sync is not supported. Skipping.
[Debug - 13:19:36.989] Incremental hotspot sync is not supported. Skipping.
[Error - 13:19:37.340] Analysis failed
java.lang.IllegalStateException: Unable to list files in directory /home/abond/src/torreys_peak
	at org.sonarsource.sonarlint.ls.util.FileUtils.allRelativePathsForFilesInTree(FileUtils.java:96)
	at org.sonarsource.sonarlint.ls.util.FileUtils.allRelativePathsForFilesInTree(FileUtils.java:85)
	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.computeProjectBinding(ProjectBindingManager.java:221)
	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$getBinding$0(ProjectBindingManager.java:185)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getBinding(ProjectBindingManager.java:178)
	at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getBinding(ProjectBindingManager.java:146)
	at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyze(AnalysisTaskExecutor.java:190)
	at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.lambda$analyze$2(AnalysisTaskExecutor.java:159)
	at java.base/java.util.HashMap.forEach(Unknown Source)
	at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyze(AnalysisTaskExecutor.java:159)
	at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.run(AnalysisTaskExecutor.java:131)
	at org.sonarsource.sonarlint.ls.AnalysisScheduler.lambda$analyzeAsync$1(AnalysisScheduler.java:241)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.nio.file.AccessDeniedException: /home/abond/src/torreys_peak/torreys/zc702/release_0.2.0/root/var/lib/sudo
	at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(Unknown Source)
	at java.base/java.nio.file.Files.newDirectoryStream(Unknown Source)
	at java.base/java.nio.file.FileTreeWalker.visit(Unknown Source)
	at java.base/java.nio.file.FileTreeWalker.next(Unknown Source)
	at java.base/java.nio.file.Files.walkFileTree(Unknown Source)
	at java.base/java.nio.file.Files.walkFileTree(Unknown Source)
	at org.sonarsource.sonarlint.ls.util.FileUtils.allRelativePathsForFilesInTree(FileUtils.java:94)
	... 17 more

Hey @abond, thank you for your post, nice find :face_in_clouds: :smiley:

I was able to reproduce and it is not limited to C++ analysis only :frowning:

Here is the ticket you can use to track progress. At the moment I cannot give any specifics on when we will be able to work on it.

Thanks again,
Sophio from :sonarlint_vscode: