Build-wrapper-dump.json does not match analyzer 6.20.4.45706 version

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

  • what are you trying to achieve

    • We analyze c++ projects using azure devops. Since about two weeks our analysis fails:
 D:\w\84\s\build_wrapper_output_directory\build-wrapper-dump.json was generated using 6.20.3 build-wrapper version, which does not match analyzer 6.20.4.45706 version.

We can see that build-wrapper-dump.json is generated.
We can also see that the build-wrapper.log contains the line

Tue Apr 26 14:26:27 2022: build-wrapper, version 6.20.3 (win-x86-64)
  • what have you tried so far to achieve this
  1. Prepare analysis in Azure Devops with the following config:
#Exclude release solutions
#sonar.exclusions=**/275/s/dev/**

sonar.sourceEncoding=windows-1252
sonar.cfamily.build-wrapper-output=$(build.sourcesDirectory)\build_wrapper_output_directory
sonar.cfamily.threads=4

sonar.projectVersion=$(Build.BuildNumber)

sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml
sonar.cs.vstest.reportsPaths=**/*.trx

sonar.cpp.vscoveragexml.reportsPaths=**/*.coveragexml
sonar.cpp.vstest.reportsPaths=**/*.trx

#Exclude Cpp from build
#sonar.c.file.suffixes=-
#sonar.cpp.file.suffixes=-
#sonar.objc.file.suffixes=-
  1. We download the build-wrapper from our sonar instance:
$name="build-wrapper-win-x86"
Invoke-WebRequest -URI https://sonar.example.com/static/cpp/build-wrapper-win-x86.zip -OutFile "$name.zip"
Expand-Archive -LiteralPath ".\$name.zip" -DestinationPath build-wrapper
cd $(build.sourcesDirectory)\Dev\Pro
&  $(build.sourcesDirectory)\build-wrapper\$name\build-wrapper-win-x86-64.exe --out-dir  "$(build.sourcesDirectory)\build_wrapper_output_directory" MSBuild.exe ProCppCodeAnalysis.proj /t:Rebuild
  1. Run Code Analysis
ERROR: Exception in thread pool-1-thread-1
##[error]java.nio.file.InvalidPathException: Trailing char < > at index 70: D:/w/79/s/Dev/Pro/Src/UserInterface/Modules/InetoptPro/detailtextdlg.h 
	at sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
	at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
	at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
	at sun.nio.fs.WindowsPath.parse(Unknown Source)
	at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
	at java.nio.file.Paths.get(Unknown Source)
	at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:40)
	at com.sonar.cpp.plugin.CFamilySensor.computeCanonicalPath(CFamilySensor.java:1056)
	at java.util.HashMap.computeIfAbsent(Unknown Source)
	at com.sonar.cpp.plugin.CFamilySensor.save(CFamilySensor.java:762)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:736)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.nio.file.InvalidPathException: Trailing char < > at index 70: D:/w/79/s/Dev/Pro/Src/UserInterface/Modules/InetoptPro/detailtextdlg.h 
	at sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
	at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
	at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
	at sun.nio.fs.WindowsPath.parse(Unknown Source)
	at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
	at java.nio.file.Paths.get(Unknown Source)
	at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:40)
	at com.sonar.cpp.plugin.CFamilySensor.computeCanonicalPath(CFamilySensor.java:1056)
	at java.util.HashMap.computeIfAbsent(Unknown Source)
	at com.sonar.cpp.plugin.CFamilySensor.save(CFamilySensor.java:762)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:736)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
##[error]at java.lang.Thread.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

  • So overall it seems that sonar provides us build-wrapper version 6.20.3 but the analysis seems to expect 6.20.4 ?

  • In addition we have the strange exception that does not happen during a normal build

Hey there.

For this exception:

Take a look at this thread:

This should solve the analysis failure.

:man_facepalming: Looks like we might have forgotten to bump the version. This is a warning you can safely ignore, and I’ll ping internally about this.

That’s rather weird.

When I checkout the code and check that file, there are no trailing spaces at the end of the file.

We have this issue since about two weeks since an update of sonar, the code did not change in the last two weeks.

Could this be another bug in the build-wrapper?
Is the build-wrapper open source? :wink: Kinda want to read the code to understand what’s happening

Hey there.

The build wrapper is not open source. :confused:

I would encourage you to take a look at the machine where the build takes place and see if you find the trailing space, rather than a local checkout.

#include "detailtextdlg.h "

This include statement in the cpp code is the reason :wink:

However, cpp compilers usually can handle this without failing.
So it would be better to trim paths see this as a codesmell instead of failing the build in my opinion

Hello @Bree,

It is not about build-wrapper or C++ compilers. The file name(not the file content) contains a trailing whitespace. This is invalid file name on windows and raise an exception on the Java nio API. You should sinply rename the file to not include a space at the end.

Thanks,

Nope, the actual file names are fine :wink:

The resolving of the includes in c++ causes this issue.

Something like this

#include "detailtextdlg.h "

Will be resolved to a path with trailing whitespaces, which causes the error in WindowsPathParser.

The Issue is solved by executing regex search and replace of all include statements that contained a trailing space, for example, #include "detailtextdlg.h " to #include "detailtextdlg.h"

i.e: our builds are green again :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.