Sonar Scanner issue with cl.exe in CMake build system

Hi all,
our MSVC 2017 build takes place via a batch file which uses CMake:
build_v2 -c -g -b -i VSLOGGER
I attach the result from
D:\VSCARE\tools>C:\build-wrapper-win-x86\build-wrapper-win-x86\build-wrapper-win-x86-64.exe --out-dir . cmd /c “build_v2 -c -g -b -i VSLOGGER”
(note I also tried calling build_v2 directly without cmd /c.)

I get these errors from the analysis. Can anyone help? thanks, Neil

log files attached.logs.zip (42.9 KB)

D:\VSCARE\tools>sonar-scanner
INFO: Scanner configuration file: c:\sonar-scanner-msbuild-5.1.0.28487-net5.0\sonar-scanner-4.4.0.2170\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\VSCARE\tools\sonar-project.properties
INFO: SonarScanner 4.4.0.2170
INFO: Java 1.8.0_51 Oracle Corporation (64-bit)
INFO: Windows 8.1 6.3 amd64
INFO: User cache: C:\Users\CW-TEST.sonar\cache
INFO: Scanner configuration file: c:\sonar-scanner-msbuild-5.1.0.28487-net5.0\sonar-scanner-4.4.0.2170\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\VSCARE\tools\sonar-project.properties
INFO: Analyzing on SonarQube server 8.7.1
INFO: Default locale: “fr_FR”, source code encoding: “UTF-8”
WARN: SonarScanner will require Java 11 to run starting in SonarQube 9.x
INFO: Load global settings
INFO: Load global settings (done) | time=235ms
INFO: Server id: BF41A1F2-AXhDFB2OhrJEsHfP65CT
INFO: User cache: C:\Users\CW-TEST.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=218ms
INFO: Load/download plugins (done) | time=625ms
INFO: Loaded core extensions: developer-scanner
INFO: JavaScript/TypeScript frontend is enabled
INFO: Process project properties
INFO: Process project properties (done) | time=16ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=0ms
INFO: Project key: my:VSCARE
INFO: Base dir: D:\VSCARE\tools
INFO: Working dir: D:\VSCARE\tools.scannerwork
INFO: Load project settings for component key: ‘my:VSCARE’
INFO: Load project settings for component key: ‘my:VSCARE’ (done) | time=188ms
INFO: Load project branches
INFO: Load project branches (done) | time=187ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=203ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=0ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=218ms
INFO: Load active rules
INFO: Load active rules (done) | time=5251ms
INFO: Indexing files…
INFO: Project configuration:
INFO: Excluded sources: C:/Users/CARDIA~1/AppData/Local/Temp/
INFO: Load project repositories
INFO: Load project repositories (done) | time=203ms
INFO: 2240 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for c: Sonar way
INFO: Quality profile for cpp: Sonar way
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for py: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module VSCARE
INFO: JavaScript/TypeScript frontend is enabled
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=187ms
INFO: Sensor CSS Metrics [cssfamily]
INFO: Sensor CSS Metrics [cssfamily] (done) | time=343ms
INFO: Sensor CSS Rules [cssfamily]
ERROR: CSS rules were not executed. Error when running: ‘node -v’. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: ‘node -v’. Is Node.js available during analysis?
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:80)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:181)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:159)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:134)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.initNodeCommand(CssAnalyzerBridgeServer.java:157)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServer(CssAnalyzerBridgeServer.java:107)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServerLazily(CssAnalyzerBridgeServer.java:177)
at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:99)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$890/2147388034.run(Unknown Source)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:389)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:354)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program “node”: CreateProcess error=2, Le fichier spécifié est introuvable
at java.lang.ProcessBuilder.start(Unknown Source)
at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:159)
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:76)
… 38 common frames omitted
Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
… 41 common frames omitted

INFO: Sensor CSS Rules [cssfamily] (done) | time=5563ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor JavaXmlSensor [java]
INFO: 2 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=125ms
INFO: 2/2 source files have been analyzed
INFO: Sensor HTML [web]
WARN: Invalid character encountered in file D:/VSCARE/tools/Graphviz2.38/bin/GVedit.html at line 179 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Invalid character encountered in file D:/VSCARE/tools/Graphviz2.38/share/graphviz/doc/html/GVedit.html at line 179 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
INFO: Sensor HTML [web] (done) | time=4125ms
INFO: Sensor XML Sensor [xml]
INFO: 2 source files to be analyzed
INFO: Sensor XML Sensor [xml] (done) | time=100ms
INFO: 2/2 source files have been analyzed
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor Python Sensor [python]
INFO: Starting global symbols computation
INFO: 3 source files to be analyzed
INFO: Starting rules execution
INFO: 3/3 source files have been analyzed
INFO: 3 source files to be analyzed
INFO: Sensor Python Sensor [python] (done) | time=2078ms
INFO: 3/3 source files have been analyzed
INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=141ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Sensor PythonXUnitSensor [python] (done) | time=109ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor JavaScript analysis [javascript]
INFO: Deploying custom rules bundle jar:file:/C:/Users/CW-TEST/.sonar/cache/f2d4f3985cfdc8a536978941e81bc342/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to D:\VSCARE\tools.scannerwork.sonartmp\eslint-bridge-bundle\package\custom-rules2007838121552870973
ERROR: Error when running: ‘node -v’. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: ‘node -v’. Is Node.js available during analysis?
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:81)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:181)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:159)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:134)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(EslintBridgeServerImpl.java:169)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:118)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServerLazily(EslintBridgeServerImpl.java:186)
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.startBridge(AbstractEslintSensor.java:145)
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:119)
at org.sonar.plugins.javascript.eslint.JavaScriptEslintBasedSensor.execute(JavaScriptEslintBasedSensor.java:51)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$890/2147388034.run(Unknown Source)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:389)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:354)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program “node”: CreateProcess error=2, Le fichier spécifié est introuvable
at java.lang.ProcessBuilder.start(Unknown Source)
at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:162)
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:77)
… 40 common frames omitted
Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
… 43 common frames omitted

INFO: Sensor JavaScript analysis [javascript] (done) | time=4360ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=31ms
INFO: Sensor Python HTML templates processing [securitypythonfrontend]
INFO: Found no ‘settings.py’ files in the project. We will consider ‘autoescape’ project option enabled.
INFO: Sensor Python HTML templates processing [securitypythonfrontend] (done) | time=297ms
INFO: Sensor CFamily [cpp]
INFO: CFamily plugin version: 6.17.0.27551
INFO: Using build-wrapper output: D:\VSCARE\tools\build-wrapper-dump.json
INFO: Available processors: 16
WARN:
CFamily plugin supports multithreaded analysis:

  • to enable multithreaded analysis
    please specify the number of threads to use
    by setting the following property to your analysis:
    sonar.cfamily.threads=number_of_threads

  • if you do not want to enable multithreading
    please explicitly disable it
    by setting the following property to your analysis:
    sonar.cfamily.threads=1

  • visit the documentation page for more information
    http://localhost:9000/documentation/analysis/languages/cfamily/

INFO: Using 1 thread for analysis according to value of “sonar.cfamily.threads” property.
WARN:
CFamily plugin supports incremental analysis with the use of a cache:

  • if you do not want to enable cache
    please explicitly disable it
    by setting the following property to your analysis:
    sonar.cfamily.cache.enabled=false

  • to enable cache please specify the following 2 options:
    sonar.cfamily.cache.enabled=true
    sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

  • visit the documentation page for more information
    http://localhost:9000/documentation/analysis/languages/cfamily/

WARN:
File
D:\VSCARE\tools\build-wrapper-dump.json
was generated using 6.15 build-wrapper version,
which does not match analyzer 6.17.0.27551 version.

Please download matching version from the server
http://localhost:9000/static/cpp/build-wrapper-win-x86.zip

INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 0 (forceInclude=0,throughHeader=0)
INFO: SE: 0 out of 0
INFO: Subprocess(es) done in 16ms
INFO: 0 compilation units analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 29.814s
INFO: Final Memory: 103M/1583M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • you are correctly invoking the scanner with correct configuration
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • you are providing the path to the correct build-wrapper output directory
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:440)
    at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
    at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
    at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:389)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:354)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
    ERROR:
    ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

D:\VSCARE\tools>

Hi @neillangmead.

The following warning seems relevant:

Hi @neillangmead ,

thank you for the nice report, a couple of things looking at your files:

  • in build-wrapper-dump.json I see that sources are in D:\VSCARE\VSLOGGER\sources\src\ and you are running from D:\VSCARE\tools\ this is why nothing is matched between the indexed files and the ones in build-wrapper-dump.json
  • looking at your build_v2.bat you may want to add --clean-first to cmake --build command

thank you Duncan. I downloaded the matching build wrapper but unfortunately still get the same error. thanks, neil

hi @mpaladin , thank you for your helpful response. I added the clean-first option to cmake build. For us, the build command is invoked from the tools directory, and the sources are in a different tree. Is this a problem for the sonar scanner? how can I solve this? should I try to port the build script so it runs under the sources/src directory?
thanks, neil

Hi @neillangmead ,

just change the directory to the sources directory before launching it.