Sonarqube in Azure Pipelines : Cannot delete directory: .sonarqube\out

Hello everybody,
I encoutered the same problem mentionned in this old topic : SQ creating really long file names

I want to scan a project during a CI Pipeline on Azure DevOps 2020 On Premise (as usual). But for some reason, for this specific project, i get this error :
Failed to create an empty directory 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out

I thought it was due to a file path too long but the max i could mesure on this project was 205 caracters, so i doubt it.

Version of Tools

  • SonarScanner for MSBuild 5.13.0 on Azure DevOps 2020 pipeline (running on Windows Agent).
  • Sonarqube Data Center Edition Version 9.9.1
  • Project to Analyse is written in c# and contains .js files in wwwroot/src (we exclude wwwroot/lib from analysis of course)

Here are the logs of the pipeline step Prepare Sonarqube Analysis

SonarScanner for MSBuild 5.13

Using the .NET Framework version of the Scanner for MSBuild

Default properties file was found at D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml

Loading analysis properties from D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml

sonar.verbose=true was specified - setting the log verbosity to 'Debug'

Pre-processing started.

Preparing working directories...

Using environment variables to determine the download directory...

Using environment variable 'AGENT_BUILDDIRECTORY', value 'D:\APPLI\AzureDevOps-Agent\_work\2598'

Cannot delete directory: 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out' because Could not find a part of the path 'D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs'..

Cannot delete file: 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out\.sonar\mod0\ucfg2\js\D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs' because Could not find a part of the path 'D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs'..

14:28:31.59 14:28:31.574 Loading analysis properties from D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml

14:28:31.59 14:28:31.59 sonar.verbose=true was specified - setting the log verbosity to 'Debug'

14:28:31.606 Updating build integration targets...

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore

14:28:31.606 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\SVCPBIPE8Build\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore

14:28:31.606 Installed SonarQube.Integration.targets to D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\bin\targets

14:28:31.606 Creating config and output folders...

14:28:31.606 Creating directory: D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\conf

14:28:31.606 Removing the existing directory: D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out

##[error]14:28:31.621 Failed to create an empty directory 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.

Detailed error message: Could not find a part of the path 'D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs'.

##[debug]Processed: ##vso[task.logissue type=error;]14:28:31.621 Failed to create an empty directory 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.%0D%0A Detailed error message: Could not find a part of the path 'D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs'.

14:28:31.621 Failed to create an empty directory 'D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.

Detailed error message: Could not find a part of the path 'D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs'.

##[error]14:28:31.621 Pre-processing failed. Exit code: 1

##[debug]Processed: ##vso[task.logissue type=error;]14:28:31.621 Pre-processing failed. Exit code: 1

14:28:31.621 Pre-processing failed. Exit code: 1

##[debug]Exit code 1 received from tool 'D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'

##[debug]STDIO streams have closed for tool 'D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'

##[debug]task result: Failed

##[error]The process 'D:\APPLI\AzureDevOps-Agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.13.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1

I would love some help to understand the behavior here and some guidance on a workaround if it exists.

Thanks everybody :slight_smile:

Hi Lucas, @Unshortafleur

it seems that analysis creates the file that exceeds 260 character limit of Windows (called MAX_PATH).

The path below has 270 characters

D:\APPLI\AzureDevOps-Agent\_work\2598\.sonarqube\out\.sonar\mod0\ucfg2\js\D__APPLI_AzureDevOps_Agent__work_2598_s_Portail_wwwroot_src_components_console_module_edit_console_module_components_specific_property_format_component_specific_property_format_component_js.ucfgs

Would it be possible for you to configure the windows agent to enable long path support? You can find many guides online, like this one

I am trying to understand why we created such a long path. It was an issue that was fixed, but somehow, we still do it in your case.

Also, this seems to happen before analysis, so it could be a leftover artifact from some previous run? Can you destroy and recreate the agent (or volume with filesystem)

1 Like

I created the ticket to fix this problem

https://sonarsource.atlassian.net/browse/SONARSEC-5500

However, it’s unlikely this will be backported to the 9.9 version, since we only backport security issues. It will be fixed in some future version

1 Like

This seems the working directory of your build agent. As I had in the past also issues (deleting of files failed), I name always the working directory of my agent D:\_1\. This solved in my case the problem, as the initial path (inckuding file name) was only about 260 chars.

1 Like

Thank you all for your responses, i will communicate the answers to my System team.

However, it’s unlikely this will be backported to the 9.9 version, since we only backport security issues. It will be fixed in some future version

NP, we will keep updating to the latest LTS, backport is usually hell of a work so i understand.
We will try to enable long path support on Windows and see what we can do from there.

Thanks a lot !

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