#11110·dvc

Windows: temporary `dvc-clone` directories are left behind after `import`/`pull`/`status` (`[WinError 32]` on a pack file)

Author: greg-lackeyCreated Sep 29, 2026Updated Sep 29, 2026

Bug Report

Description

On Windows, every command that clones the source repo of an imported dataset (dvc import, dvc pull, dvc status, dvc repro -f, dvc exp run) finishes successfully but fails to delete its temporary clone:

WARNING: Failed to remove '..\..\..\AppData\Local\Temp\1\tmppevqw_judvc-clone' - [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\<user>\\AppData\\Local\\Temp\\1\\tmppevqw_judvc-clone\\.git\\objects\\pack\\pack-b283e59646abf7a0956509954723015520ca79d3.pack'

The command's own work succeeds. But a tmp*dvc-clone directory is left in %TEMP% on every run, so they pile up in a project that uses dvc import.

This has been reported before: #6919 (dvc update, 2021) and #10512 (dvc pull, 2024). Both were closed without a fix (#10512 as stale), and #6919's reporter moved to WSL. #9749 may be related: its latest comment says WinError 32 happens specifically on dvc import on Windows.

Reproduce

On Windows, in any DVC project:

powershell
dvc import https://github.com/<owner>/<dvc-repo> <path/to/tracked/dir> -o data/raw/x

Watch for the warning after the import completes, then:

powershell
Get-ChildItem "$env:TEMP\*dvc-clone"      # one leftover directory per run

It happens on every run for us, over HTTPS with Git Credential Manager, from PowerShell, with no editor or other process touching %TEMP%.

Expected

The temporary clone is removed, as it is on Linux and macOS.

Where it seems to come from

dvc/repo/open_repo.py::_remove retries the delete 5 times, 0.1 s apart (retry(5, errors=OSError, timeout=0.1)), then logs this warning. _clone_default_branch does call git.close() on the clone before that.

The lock appears to be held by DVC's own process: once dvc exits, the same directory deletes without error (Remove-Item "$env:TEMP\*dvc-clone" -Recurse -Force). So retrying inside the process can't succeed.

A pack-file handle is probably still open in-process after git.close(). It may be worth checking whether every scmrepo backend (dulwich, and pygit2/libgit2, which can memory-map packs) releases its pack files on close. Also whether any other object opened on the clone (for example during _pull, or before copytree into the dvc-erepo copy) is still alive at cleanup.

Environment information

Output of dvc doctor:

bash
DVC version: 3.67.1 (conda)
---------------------------
Platform: Python 3.13.15 on Windows-11-10.0.26200-SP0
Subprojects:
        dvc_data = 3.18.3
        dvc_objects = 5.2.0
        dvc_render = 1.0.2
        dvc_task = 0.40.2
        scmrepo = 3.6.2
Supports:
        http (aiohttp = 3.14.3, aiohttp-retry = 2.9.1),
        https (aiohttp = 3.14.3, aiohttp-retry = 2.9.1)
Config:
        Global: C:\Users\<user>\AppData\Local\iterative\dvc
        System: C:\ProgramData\iterative\dvc
Cache types: hardlink
Cache directory: NTFS on C:\
Caches: local
Remotes: None
Workspace directory: NTFS on C:\
Repo: dvc, git
Repo.site_cache_dir: C:\ProgramData\iterative\dvc\Cache\repo\0c86e8304a01971b3f5a8e46233ce4eb

Additional Information:

  • Windows, PowerShell, conda environment; %TEMP% is a per-session folder (AppData\Local\Temp\1\).
  • Source repo accessed over HTTPS (Git Credential Manager).
  • Workaround: sweep %TEMP%\*dvc-clone after dvc exits.