Skip to content

Access is denied error on windows when uv sync #15968

Closed as duplicate
Closed as duplicate

Description

@cruzzil

Summary

Hi,

Within a corporate environment, when running uv sync or uv add, I often get an Access is denied. (OS error 5) when it is trying to delete a directory. E.g. "Failed to remove directory C:\mylib.venv\Lib\site-packages\polars-123.data". It is usually the data or pycache

I'm unable to replicate this outside of a corporate environment, and cannot provide logs due to company policy. To resolve it I need to run uv sync / uv add multiple times, depending on the number of dependencies/transistive dependencies, can be 50+ times.

The trace shows the error coming from remove_dir_all

I don't see this problem with other package managers like pnpm / cargo, etc.

Potential solution could be using this package which helps with lock issues on Windows: https://crates.io/crates/remove_dir_all

Platform

Windows 11 x86_64

Version

0.8.19

Python version

3.13.5

Activity

  1. added
    bug
    on Sep 21, 2025
  2. added
    area:windows
    needs-mre
    on Sep 23, 2025
  3. retropc commented on Oct 31, 2025

    @retropc

    I've seen this too

    uv add ruff ->

    error: Failed to install ruff-0.14.1-py-none-win_amd64.wsl (ruff==0.14.1)
      Caused by: failed to remove directory `C:\.......\.venv\Lib\site-packages\ruff-0.14.1.data`: The filename, directory name, or volume label syntax is incorrect. (os error 123)
    

    most likely defender is holding the directory open, need to wait and retry a few times

    terrible but that's Windows for you

  4. Ndnes commented on Nov 21, 2025

    @Ndnes

    Not sure if this is the same exact issue, but I am also having problems with Windows Defender. I can not run uv at all though, and I had the same issue with pip as well. This is definitely something local IT / Windows should deal with, but I'll provide the log from Event Viewer anyways.

    The event was triggered when running the command "uv --version" in command prompt.

    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
    <Provider Name="Microsoft-Windows-Windows Defender" Guid="{11cd958a-c507-4ef3-b3f2-5fd9dfbd2c78}" /> 
    <EventID>1121</EventID> 
    <Version>0</Version> 
    <Level>3</Level> 
    <Task>0</Task> 
    <Opcode>0</Opcode> 
    <Keywords>0x8000000000000000</Keywords> 
    <TimeCreated SystemTime="2025-11-21T12:54:16.9075113Z" /> 
    <EventRecordID>1688</EventRecordID> 
    <Correlation ActivityID="{4c4fd6cc-21e3-43e3-9c9e-cfc6f13f4fdd}" /> 
    <Execution ProcessID="19856" ThreadID="24948" /> 
    <Channel>Microsoft-Windows-Windows Defender/Operational</Channel> 
    <Computer>***</Computer> 
    <Security UserID="S-1-5-18" /> 
    </System>
    <EventData>
    <Data Name="Product Name">Microsoft Defender Antivirus</Data> 
    <Data Name="Product Version">4.18.25100.9008</Data> 
    <Data Name="Unused" /> 
    <Data Name="ID">01443614-CD74-433A-B99E-2ECDC07BFC25</Data> 
    <Data Name="Detection Time">2025-11-21T12:54:16.906Z</Data> 
    <Data Name="User">***</Data> 
    <Data Name="Path">C:\Users\***\.local\bin\uv.exe</Data> 
    <Data Name="Process Name">C:\Windows\System32\cmd.exe</Data> 
    <Data Name="Security intelligence Version">1.441.381.0</Data> 
    <Data Name="Engine Version">1.1.25100.9002</Data> 
    <Data Name="RuleType">ENT\ConsR</Data> 
    <Data Name="Target Commandline" /> 
    <Data Name="Parent Commandline">"C:\WINDOWS\system32\cmd.exe"</Data> 
    <Data Name="Involved File" /> 
    <Data Name="Inhertiance Flags">0x00000000</Data> 
    </EventData>
    </Event>
    
  5. Enferlain commented on Feb 13, 2026

    @Enferlain
  6. cruzzil commented on Feb 14, 2026

    @cruzzil
    Author

    Interestingly I have found that the issue pretty much disappears if I open a fresh powershell and don't use the VScode terminal

  7. RomanPszonka commented on Jun 30, 2026

    @RomanPszonka

    @woodruffw I'd like to work on this;

    My solution follows an established pattern of retrying operations on Windows, but delete was left out.

    Initial draft at https://github.com/RomanPszonka/uv/pull/1/changes.

    I can consider generalising it for retry mechanism of other operations on Windows (persist_with_retry_sync, persist_with_retry, with_retry_sync, rename_with_retry), if that would be a preference.

    There is already // TODO(zanieb): Look into reusing this code? suggestion for that from @zanieb

  8. Spectre5 commented on Jul 14, 2026

    @Spectre5

    @RomanPszonka are you still planning to submit this as a PR? I see you have 2 PRs in your own fork. I'd love for this to make its way into uv.

  9. RomanPszonka commented on Jul 14, 2026

    @RomanPszonka

    @Spectre5 happy to... not sure what's the procedure. If any of maintainers could confirm which solution would be more acceptable?

  10. Spectre5 commented on Jul 14, 2026

    @Spectre5

    @zanieb - there have been a handful of duplicates closed and linked to this issue, any chance some input by a maintainer can be provided here?

  11. woodruffw commented on Jul 29, 2026

    @woodruffw
    Member

    Triage: deduping with #20792. Please help us make uv better by contacting your AV/EDR vendor per the info in that issue!

  12. cruzzil commented on Aug 1, 2026

    @cruzzil
    Author

    I don't think this is antivirus related. This is some behaviour difference when using the terminal inside vscode vs using a standard powershell terminal. Also given uv is the only thing that suffers from this (pip, cargo, etc...all work fine) makes it feel like this is definitely uv related and how it handles deleting files in windows.

    I think this should be re-opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:windowsbugneeds-mre

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions