sonarQube fails on file path too long 261 characters on windows

We get the an llegalStateException exception on Windows 10 Enterprise. ( see sonar-scanner output section bellow ) when parsing a file that as a very long path.

The string that fails as exactly 261 characters which is 1 more then the typical limit of a shell.
It actually is the second time we get this problem, the first time we did a temporary fix by getting rid of a couple of characters in some folders.

I tried setting
Set-ItemProperty ‘HKLM:\System\CurrentControlSet\Control\FileSystem’ -Name ‘LongPathsEnabled’ -value 1
In a powershell and then calling manually sonar-scanner.bat but I get the same error.
I’m trying to call java directly from powershell not from the batch file with the following powershell script but I it fails with : java.lang.ClassNotFoundException: org.sonarsource.scanner.cli.Main error.

And I think I might be beating a dead horse here.

$java="C:\Program Files\Common Files\Oracle\Java\javapath\java.exe" 

& $java $cp $cli $scanhome $prjhome $main

Any hints or guide lines would be appreciated to figure out where I should search to get the shell or java to support more then 260 characters.


sonar-scanner output

2022-09-30T19:56:25.0864618Z ##[section]Starting: SonarQube Analysis
2022-09-30T19:56:25.1072207Z ==============================================================================
2022-09-30T19:56:25.1072467Z Task : Run Code Analysis
2022-09-30T19:56:25.1072682Z Description : Run scanner and upload the results to the SonarQube server.
2022-09-30T19:56:25.1072880Z Version : 4.31.0
2022-09-30T19:56:25.1073028Z Author : sonarsource
2022-09-30T19:56:25.1073422Z Help : Version: 4.31.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information
2022-09-30T19:56:25.1073857Z ==============================================================================
2022-09-30T19:56:25.3319256Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C “C:\agent_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.31.0\sonar-scanner\bin\sonar-scanner.bat”
2022-09-30T19:56:25.4923683Z INFO: Scanner configuration file: C:\agent_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.31.0\sonar-scanner\bin..\conf\
2022-09-30T19:56:25.4927103Z INFO: Project root configuration file: C:\agent_work\2\s\
2022-09-30T19:56:25.5290302Z 15:56:25.520 INFO: SonarScanner
2022-09-30T19:56:25.5290761Z 15:56:25.528 INFO: Java 11.0.12 Oracle Corporation (64-bit)
2022-09-30T19:56:25.5291041Z 15:56:25.528 INFO: Windows 10 10.0 amd64
2022-09-30T19:56:25.5292726Z 15:56:25.528 INFO: SONAR_SCANNER_OPTS=“\Program Files\Java\jdk-17.0.1\lib\security\cacerts\Program Files\Java\jdk-17.0.1\lib\security\cacerts”

java.lang.IllegalStateException: c:\st\stm32cubeide\plugins\\tools\bin../lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/include/c++/10.3.1/arm-none-eabi/thumb/v7-m/nofp\bits/c++allocator.h
at com.sonar.cpp.jni.FileSystemOperations.realPath(
at java.base/java.util.HashMap.computeIfAbsent(
at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(
at com.sonar.cpp.plugin.CFamilySensor.lambda$save$15(
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(
at java.base/$Head.forEach(
at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(
at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(
at java.base/java.util.concurrent.Executors$
at java.base/
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.base/java.util.concurrent.ThreadPoolExecutor$
at java.base/
2022-09-30T19:56:56.5689142Z 15:56:56.564 ERROR: Exception in thread pool-3-thread-1


Welcome to the community!

There’s a lot going on here that I don’t understand.

Leaving aside the 53-char job name(?!), it seems that you’re downloading your project for analysis into the sonar-scanner directory…?


And also, you shouldn’t need to invoke Java directly or the jar itself. Invoke the scanner script, and assuming you’ve downloaded the right version & followed the directions the script will take care of it.

Those docs I just pointed you to will also help you with the correct property names and which ones you need.

Thanks for the reply,
I reverted the code I was trying to do run in powershell and I’m using the original configuration.
I believe that scanhome and prjhome folders pointing in the wrong folders are artefacts of me trying stuff out

The real problem seems to be when we scan

Which is exactly 261 character long path. And these paths are installed/generated by stm32CubeIde so I have very little control on there installation path. Is there a way to get around the 260 character limit when scanning ?

I’ll try to see if I can shorten the path but the feels more like a patch then a true fix. And at first glance I believe I only have control over parts of the path “c:\st\stm32cubeide”