Command Error: Re-run SonarScanner using the -X switch to enable full debug logging

To analyze, I enter the necessary commands in the command line in the directory where the project is located and I encounter these errors.
I hope I was able to explain, what exactly is the problem here?

ERROR: Error during SonarScanner execution
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Hi @codeluyor,

The last message is telling you to run the analysis again with one more command-line flag: -X. It will give you more detailed logs. If that still does not help you, you can post the full analysis log here, together with your version of SonarScanner and SonarQube, as well as your OS and the “build-wrapper.log”.

Versions:
Windows 10 10.0
SonarScanner 4.7.0.2747
SonarQube 9.4.0.54424

build-wrapper.log:

> Sun May 08 07:13:23 2022: build-wrapper, version 6.32 (win-x86-64)
> Sun May 08 07:13:23 2022: isWow64: 0
> Sun May 08 07:13:23 2022: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 1
> Sun May 08 07:13:23 2022: current directory: C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main
> Sun May 08 07:13:23 2022: cwd: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main>
> Sun May 08 07:13:23 2022: out-dir absolute path: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\bw-output>
> Sun May 08 07:13:23 2022: command line received: <MSBuild.exe /t:Rebuild>

Are there any files in the “bw-output” directory?
What do you see printed when you run sonar-scanner -X ...<rest of the arguments> ?

BTW, from the name of your project directory, I suspect that you based it on our windows-cmake-gh-actions-sq example. Yet, unlike the example, you are running MSBuild.exe to build the project. You might want to checkout windows-msbuild-otherci-sq or windows-msbuild-gh-actions-sq examples - they both run MSBuild and not CMake.

There is a file “build-wrapper.log” in the “bw-output” directory.
I wanted to test it in SonarQube by following your test steps by taking one of the sample c projects, but I am getting an error. I’ve confirmed it works with MSBuild. However, I’m having trouble with the test commands.

When I run sonar-scanner -X in the directory, I get the following output.

...
...
09:13:11.499 INFO: ------------------------------------------------------------------------
09:13:11.499 INFO: EXECUTION FAILURE
09:13:11.500 INFO: ------------------------------------------------------------------------
09:13:11.502 INFO: Total time: 9.609s
09:13:11.548 INFO: Final Memory: 27M/104M
09:13:11.548 INFO: ------------------------------------------------------------------------
09:13:11.549 ERROR: Error during SonarScanner execution
java.lang.UnsupportedOperationException:

One configuration property is expected, two were found:
  "sonar.cfamily.build-wrapper-output"
  "sonar.cfamily.compile-commands"

Based on this:

One configuration property is expected, two were found:
  "sonar.cfamily.build-wrapper-output"
  "sonar.cfamily.compile-commands"

You are running sonar-scanner with two mutually exclusive properties: sonar.cfamily.build-wrapper-output and sonar.cfamily.compile-commands. They are mutually exclusive because cfamily analyzer can take the compilation configuration only from one source: either the Build Wrapper output or the compilation database (compile_commands.json). When you provide both, it gets confused.

You need to set only one of the properties: build-wrapper-output or compile-commands, but not both.

Make sure that in your “sonar-project.properties” and in your command line (where you can add properties with -D or --define) you are defining only one of them.

Got it, thanks, I fixed the problem now.
This time it gives a different error code, I wonder if there is a problem with the build wrapper?

10:38:12.196 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.nio.file.NoSuchFileException: C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\bw-output\build-wrapper-dump.json

Don’t we specify the .exe extension of our “your clean build command” source code in the command section on the bottom line? Did I misunderstand?

build-wrapper-win-x86-64.exe --out-dir bw-output <your clean build command>

Apparently, Build Wrapper did not generate the “build-wrapper-dump.json” file. Can you post the contents of “build-wrapper.log” to see what happened during Build Wrapper execution?
Also, can you tell whether <your clean build command> succeeded?

Maybe it will be helpful if I talk about the processes. First I ran the command "build-wrapper-win-x86-64.exe --out-dir bw-output main.exe".(Inside the src folder)

build-wrapper.log :

Mon May 09 11:24:28 2022: build-wrapper, version 6.32 (win-x86-64)
Mon May 09 11:24:28 2022: isWow64: 0
Mon May 09 11:24:28 2022: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 1
Mon May 09 11:24:28 2022: current directory: C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src
Mon May 09 11:24:28 2022: cwd: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src>
Mon May 09 11:24:28 2022: out-dir absolute path: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src\bw-output>
Mon May 09 11:24:28 2022: command line received: <main.exe>
Mon May 09 11:24:28 2022: initializing json file
Mon May 09 11:24:28 2022: starting debug cycle
Mon May 09 11:24:28 2022: process created with pid: 25528
Mon May 09 11:24:28 2022: image path name: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src\main.exe>
Mon May 09 11:24:28 2022: command line: <main.exe>
Mon May 09 11:24:28 2022: working directory: <C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src\>
Mon May 09 11:24:28 2022: isWow64: 1
Mon May 09 11:24:28 2022: skipping process C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src\main.exe with pid: 25528
Mon May 09 11:24:28 2022: process with pid 25528 exit with code: 0 (0x0)
Mon May 09 11:24:28 2022: finalizing json file

build-wrapper-dump.json :

# (C) SonarSource SA, 2014-2022, info@sonarsource.com
# All SONARSOURCE programs and content are copyright protected.
# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
#
# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
# It may not be used in connection with any other software.
# Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
"version":"6.32",
"captures":[
]}

As output, these two documents were placed in the directory.

The command build-wrapper-win-86-64.exe --out-dir bw-output main.exe has successfully output the source code.

Thank you for the logs and the full Build Wrapper invocation command, it is clearer now.
From this line:

Mon May 09 11:24:28 2022: skipping process C:\Users\Samet\Desktop\windows-cmake-gh-actions-sq-main\src\main.exe with pid: 25528

I can see that Build Wrapper ignored the main.exe.

From its name, I suspect main.exe is not a build command, but rather the executable that was built by a build command. For this reason, Build Wrapper skips it, as it can learn nothing from the execution of a pre-built binary.

We use Build Wrapper to capture all the details relevant to compilation of your source files. It hooks into all the compile processes that happen in <your clean build command> and extracts the environment variables, compiler executable, and compiler arguments. If you run only your executable, it will not be able to see how it was compiled.

You need to run your build command and not your built executable.

So if you are using CMake it would look something like

build-wrapper-win-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR cmake --build build/ --config Release

if you are using MSBuild, it should look like

build-wrapper-win-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR msbuild sonar_scanner_example.vcxproj /t:rebuild /nodeReuse:false

Understood thanks. I’ll take a look and try to fix it. I hope it works.

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