Windows: some times we get "fatal: destination path '*' already exists and is not an empty directory."

We use GitLab CI to test and publish node.js projects. During each build we use npm install to install all dependencies locally in the project build folder. As we use npm v2, the folder structure of each project gets really large.

Some times the build fails with the following:

gitlab-ci-multi-runner 1.2.0 (3a4fcd4)
Using Shell executor...
Running on *******...
Cloning repository...
fatal: destination path '*************************' already exists and is not an empty directory.

The destination folder is there and it is not empty. There are several subfolders remaining, but most of subfolders and file are removed. Rerunning the build does not solve the problem. I have to remove the folder manually and then rerun the build for it to succeed.

It seems to me that the problem is with CMD rd command that is used in CMD script (as it is stated in https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/shells/README.md#windows-batch). Maybe it returns before everything is deleted or it fails to delete the folder with large subfolder hierarchy. As far as I understand, the script for shell executor is constructed dynamically for each build and there is no way I can debug it.

Does anybody have any idea what can I do with this problem?

Edited by 🤖 GitLab Bot 🤖