[Issue] Sonarqube works in some projects but not others ( possibly fails to set proper "Root=" ? )

  • Operating system: Win 10
  • Visual Studio version: 2022 17.14.23
  • SonarQube for Visual Studio plugin version: 9.7.0.16245
  • Programming language you’re coding in: C++
  • Is connected mode used: No
    • SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?):

Sonarqube seems to “break” on certain projects i have.

It does nothing in those, no files are analyzed.

Meanwhile it does work in other projects.

I looked at the logs of both and i noticed that in the project that does not work, Sonarqube seems to have detected the wrong “Root=” directory.

[SLCore > Configuration Scope] Updated files system parameters for Configuration Scope MyProject: Root=P:, Commands Directory=

← Here it detects P: where the build-files are, but it should be I: where the source-files are. It detects this properly in other projects.

It then skips all source files because it can’t relativize the file towards that Root.

In the project that works, it sets the “Root=” correctly.

Both projects are Out of Source builds using CMake.

The build directories where the CMake creates all the build-files including the Visual Studio SLN, are on a different drive than the source-files.

In the project that doesn’t work, SonarQube for some reason uses the drive of the build-files as the “Root=”. In the working projects, it uses the drive of the source-files as the “Root=”

Hi,

Could you provide a verbose log from IDE startup through to where you (don’t) see the problem?

 
Thx,
Ann

Sure, here are verbose logs for working and nonworking projects.

Both have the build-files on P: and the source-files on I: ( which SonarQube should analyze ).

Is there maybe a way to set the “Root” in the settings.json, without having to add all the files that should be analyzed ?

problematic_project.txt (42.8 KB)

working_project.txt (55.1 KB)

Hi,

Thanks for the logs. I’m not sure how to set the root. I’ve flagged this for the team.

 
Ann

Hello everyone!
I have the same issue after upgrading from v.9.6. Versions from 9.0 to 9.6 works fine, but v.9.7.0, v.9.8.0 and v.9.8.1 do not start analysis of the code. The Root is set to c:\ while project is on drive g:\

working_v.9.6.txt (2.6 KB)

not_working_v9.8.1.txt (121.9 KB)

Hi. Is the project split across multiple drives? I think we might have a bug where we incorrectly assume the root based on the first file path we encounter (which can be random). Is your sln file on the same disk as the source files you’re trying to analyze?

JFYI: we did make a change on how we calculate paths in version 9.7, but I’m not really sure why that change triggered this problem for you

Hi Georgii Borovinskikh, thanks for the reply!

My project is fully located on drive G: including .sln and .vcxproj files.
I’m using Visual Studio 2026 and it is installed on drive C: (cl.exe and settings are stored on drive C:)

I’ve just checked the 9.9.0 version and it has the same issue:
SonarLint.VSIX-9.9.0.16495-2022.txt (122.9 KB)

Yeah I think it could be the library files then. Can you try the build from the artifacts of this PR? It adds some logs but also changes the logic for identifying the root (takes sln file disk as default) SLVS-2892 File System Investigation · SonarSource/sonarlint-visualstudio@b8c3350 · GitHub

I tried this build but, sadly, it does not fix the issue.
The logs:

SonarLint.VSIX-9.10.0.16499-2022.txt (292.9 KB)

Sorry, wrong PR! I will send you the correct one

Sorry again, here’s the correct PR: SLVS-2894 calculate root based on sln · SonarSource/sonarlint-visualstudio@16ba2c5 · GitHub

Georgii Borovinskikh, thanks, in works for me!
Now SonarQube analyzes files in my project, but there are still similar log entries about system headers (like `File ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\memory.h’ can’t be relativized against root ‘G:\’ and is skipped`)

Here is the log:

SonarLint.VSIX-9.10.0.16501-2022.txt (362.4 KB)

Normally those library files should be ignored anyway, as we don’t want to analyze them, but the problem is we don’t have a good way to distinguish user vs library files in VS SDK

@rebb Hi could you please also try the following build? [Issue] Sonarqube works in some projects but not others ( possibly fails to set proper "Root=" ? ) - #16 by georgii.borovinskikh

@rebb can you also explain a bit your project structure and how it’s split (or not) across different drives?

In my case the SLN is on the drive with my Build-Files ( created by CMake ).

The actual source-files are on another drive.

Roughly like this :

P: → SLN and Build-Files ( plus all the third party sources CMake gets via FetchContent )
L: → Main Source Files

I was wondering if there is maybe a way to set the SonarQube Root Drive via the settings.json or some similar mechanism, without having to list all the files that should be analyzed there.

I’m trying that build you linked now.

Seeing the same problem with this build.

But it makes sense in my case because my SLN is not on the same drive where my source files are anyway.

Or maybe have SonarQube use the Root-Drive of the current Startup Project in the SLN ?

That would make “aiming” SonarQube at the right drive fairly simple.
Just a random thought that probably would have it’s own pitfalls :smiley: