Path too long exception

Hi,

I’m getting a scanner exception on a path that is too long. When I reduce the path length, the error goes away. Long path support is enabled on Windows.

The problem looks similar to this report, but since I’m using a more recent version of the CFamily plugin, I suspect that it is actually slightly different.

My setup:

  • SonarCloud + Azure Devops Pipeline + BitBucket Cloud
  • C and C++ code
  • SonarScanner 4.6.2.2472
  • Java 18.0.1.1 Oracle Corporation (64-bit)
  • Windows 10 10.0 amd64
  • CFamily plugin version: 6.33.0.46593

Here is the message:

##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\bin\../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/include/c++/10.3.1/arm-none-eabi/thumb/v7e-m+fp/hard
	at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
	at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(CanonicalPathCache.java:17)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.sonar.cpp.analyzer.GCCBasedDriverUtil.removeIncludesWhichAreSystemIncludes(GCCBasedDriverUtil.java:218)
	at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:449)
	at com.sonar.cpp.analyzer.CompilerDrivers.onCapture(CompilerDrivers.java:35)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(CFamilySensor.java:643)
	at com.sonar.cpp.plugin.BuildWrapperJsonReader.readCaptures(BuildWrapperJsonReader.java:87)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:640)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:411)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:190)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:440)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:436)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:394)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$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)

Hi, @tzijnge
Thank you for reporting this failure, which is, indeed, different than the one in the linked post. Also thank you for identifying the cause (a path being too long). I’ve created a ticket to track the investigation of this issue: CPP-3686.
Unfortunately, I cannot say when we can handle it, but luckily you know the workaround - use a shorter path.