java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found empty

java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process
    at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:431)
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
    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

any one help for this issue,when i trying sonar scanning for CPP project getting that issue.

Hello @nagendra_jonnalagadd and welcome to our community!

Could you share the content of the build wrapper output directory?
(You should have defined it in your sonar-project.properties, see documentation: sonar.cfamily.build-wrapper-output=build_wrapper_output_directory)
I can send you a PM if you can’t share it publicly

PFA build wrapper output directory.

Now i getting below issue

15:01:52.855 INFO: ------------------------------------------------------------------------
15:01:52.856 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process
    at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:431)
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
    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:392)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
    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:149)
    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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

build_wrapper_output_directory.zip (1.32 KB)

From the log, I can see that we don’t index any file so the build-wrapper is empty and that causes the error.
One possible explanation is that your code was already compiled when you launched msbuild with the build-wrapper command. To ensure that your build is clean, could you launch the rebuild command instead of a simple build? MSBuild.exe /t:Rebuild
And if you still have this issue, please share the logs corresponding to the clean build command.

Hello team,

As mentioned i have done after that try do the scan,but getting below issue,

15:52:54.119 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.process(CFamilySensor.java:440)
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
    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:392)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
    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:149)
    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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/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)

Thanks,
Nagendra Jonnalagadda.

As before, could you share the content of the build wrapper output directory please? As well as the console output of the build + build-wrapper command. I won’t be able to understand the problem without those elements.
Thanks

Hello Team,

now am getting below issue please help .

85688.png

Hello Team,

PF the file for build wrapper output directory

// example for Windows
build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory MSBuild.exe /t:Rebuild

Thanks,
Nagendra.J.

build-wrapper-dump.json (7.61 KB)

Please note that the result of the sonar-scanner command must succeed to get any results on SonarQube. And if I understood you correctly, the result of this command is still failing in your case, so that’s why you don’t see anything on SonarQube.

So, first things first, let’s try to make your sonar-scanner command successful.
Now I can see your build-wrapper.json is not empty anymore, so launching the build wrapper with a clean build was already a good step.
But to investigate further, I would need the whole content of the build_wrapper_output_directory, not only the json file.
And if you could also send me the logs you get when launching build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory MSBuild.exe /t:Rebuild, it would be helpful.
Thanks

Hello Team,

As mentioned attached whole content of the build_wrapper_output_directory.And the analysis is successful but the code is not deployed in sonar server( the issue is :

The main branch has no lines of code.

``

12:29:31.000 INFO: Analysis report generated in C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater.scannerwork\scanner-report
12:29:31.003 DEBUG: Upload report
12:29:31.934 DEBUG: POST 200 http://172.20.1.131:9000/api/ce/submit?projectKey=CPPUpdaterClient&projectName=CPPUpdater | time=925ms
12:29:31.945 INFO: Analysis report uploaded in 938ms
12:29:31.948 DEBUG: Report metadata written to C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater.scannerwork\report-task.txt
12:29:31.949 INFO: ANALYSIS SUCCESSFUL, you can browse http://172.20.1.131:9000/dashboard?id=CPPUpdaterClient
12:29:31.950 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:29:31.952 INFO: More about the report processing at http://172.20.1.131:9000/api/ce/task?id=AXlAeYEuoXVWa5Ul5XfV
12:29:31.956 DEBUG: Post-jobs :
12:29:31.959 INFO: Analysis total time: 21.601 s
12:29:31.963 INFO: ------------------------------------------------------------------------
12:29:31.963 INFO: EXECUTION SUCCESS
12:29:31.964 INFO: ------------------------------------------------------------------------
12:29:31.965 INFO: Total time: 35.341s
12:29:32.034 INFO: Final Memory: 7M/27M
12:29:32.034 INFO: ---------------------------------

Thanks,
Nagendra.

build_wrapper_output_directory.zip (6.21 KB)

Please help me on this isue, today is last date for free license, i need to done POC

To sum up, and please read this carefully and check that is indeed what you’re doing:

  • You’re at the root of your project that contains .cpp files.
  • You launch a clean build with build-wrapper: build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory MSBuild.exe /t:Rebuild
    With build_wrapper_output_directory the same directory that is defined in your sonar-project.properties (i.e.: sonar.cfamily.build-wrapper-output=build_wrapper_output_directory)
  • You launch sonar-scanner
  • You go to your SonarQube (with the same URL than the one defined in sonar-project.properties, i.e. sonar.host.url=YourSonarQubeURL)

And then you have the message “The main branch has no lines of code”, and don’t have any results.
Is that correct?

If so, please share with me your sonar-project.properties so that I can try to figure out the problem.

Hello Team,

As you requested ,Please find the attached sonar-project.propeties file,If any i mistaken in that please guide those

queries:

  1. For cpp how to give the exclude source code files like

sonar.inclusions=
sonar.exclusions=

I have deployed sonar sonar in docker and i trying do code analysis from another windows server using sonar-scanner is that fine .

Regards,
Nagendra.J

(Attachment sonar-project.properties is missing)

Hello Team,

As you requested ,Please find the attached sonar-project.propeties file,If any i mistaken in that please guide those

queries:

  1. For cpp how to give the exclude source code files like

sonar.inclusions=
sonar.exclusions=

I have deployed sonar sonar in docker and i trying do code analysis from another windows server using sonar-scanner is that fine .

Regards,
Nagendra.J

sonar-project.zip (631 Bytes)

In your sonar-project.properties:

  • Please remove sonar.language=C++, this has been deprecated and is not useful here
  • What do you want to achieve by writing this:
    sonar.inclusions=*.cpp
    sonar.exclusions=*.cpp
    These properties take as input a relative path to the files you want to include/exclude.
    If you want to exclude a particular file, it would look something like:
    sonar.exclusions=my/path/to/myFile.cpp

For the analysis to work correctly, build and analysis should be done on the same environment, because we need to access the same files used during build in order to get you accurate analysis. It does not seem to be your case from what you describe, so that’s why it does not work.

Hello Team,

I tried as you mentioned steps,But getting below issue

i have Modified sonar.proeject propeties file,but still getting issue please check

Thanks,
Nagendra.J

Hello Team,

I tried as you mentioned steps,But getting below issue

i have Modified sonar.proeject propeties file,but still getting issue please check

17:37:33.825 DEBUG: ‘Indexer.cpp’ generated metadata with charset ‘UTF-8’
17:37:33.843 DEBUG: ‘packages/curl-vc140-static-32_64.7.53.0/lib/native/include/curl/typecheck-gcc.h’ generated metadata with charset ‘UTF-8’
17:37:33.890 DEBUG: ‘packages/openssl-vc140-static-32_64.1.1.0/lib/native/include/openssl/ssl2.h’ generated metadata with charset ‘UTF-8’
17:37:33.895 DEBUG: ‘ServerInfoStruct.h’ generated metadata with charset ‘UTF-8’
17:37:33.897 DEBUG: Not enough content in ‘ServerInfoStruct.h’ to have CPD blocks, it will not be part of the duplication detection
17:37:33.995 INFO: ------------------------------------------------------------------------
17:37:33.996 INFO: EXECUTION FAILURE
17:37:33.996 INFO: ------------------------------------------------------------------------
17:37:33.997 INFO: Total time: 16.093s
17:37:34.047 INFO: Final Memory: 19M/74M
17:37:34.047 INFO: ------------------------------------------------------------------------
17:37:34.048 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.nio.file.NoSuchFileException: C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater\build_wrapper_output_directory\build-wrapper-dump.json
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:611)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:360)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
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:392)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
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:149)
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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/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.nio.file.NoSuchFileException: C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater\build_wrapper_output_directory\build-wrapper-dump.json
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
at java.base/java.nio.file.Files.newByteChannel(Unknown Source)
at java.base/java.nio.file.Files.newByteChannel(Unknown Source)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(Unknown Source)
at java.base/java.nio.file.Files.newInputStream(Unknown Source)
at java.base/java.nio.file.Files.newBufferedReader(Unknown Source)
at java.base/java.nio.file.Files.newBufferedReader(Unknown Source)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:537)
… 30 more

C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater>sonar-scanner -Dsonar.login=8271819e7474f918d88439db7a44ac99d83098f0 -X

Thanks,
Nagendra.j

sonar-project.zip (658 Bytes)

Hello Team,

Please ignore last mail now i am getting below issue after modifying project properties file

18:06:44.726 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.process(CFamilySensor.java:440)
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
    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:392)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
    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:149)
    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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/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)

Thanks,
nagendra.j

sonar-project.zip (658 Bytes)

Can you confirm that you’re doing both compilation with build-wrapper and analysis in the same environment?
If not, it can not work.

If so, as before, please share the entire log output of your clean build command with the build wrapper as well as the files that are in your build_wrapper_output_directory