Skip to content

fix(windows): handle read-only git pack files causing WinError 5 on amplifier update#152

Open
hoopsomuah wants to merge 2 commits intomicrosoft:mainfrom
anokye-labs:main
Open

fix(windows): handle read-only git pack files causing WinError 5 on amplifier update#152
hoopsomuah wants to merge 2 commits intomicrosoft:mainfrom
anokye-labs:main

Conversation

@hoopsomuah
Copy link
Copy Markdown
Member

@hoopsomuah hoopsomuah commented Mar 24, 2026

Fixes microsoft/amplifier#241

Problem

On Windows, amplifier update fails with [WinError 5] Access is denied when clearing cached module and bundle directories. Git pack files (.git/objects/pack/*.idx) are created read-only on Windows, and shutil.rmtree() doesn't handle this.

Example output:

Could not clear ...amplifier-module-context-simple-...: [WinError 5] Access is denied: ...\.idx
Could not clear ...amplifier-module-hooks-logging-...: [WinError 5] Access is denied: ...\.idx
...
⚠ Update completed with errors
  ✗ Bundle: amplifier: [WinError 5] Access is denied: ...
  ✗ Bundle: browser-tester: [WinError 5] Access is denied: ...

Fix

Add rmtree_safe() helper in amplifier_app_cli/utils/cache_management.py with an error handler that strips the read-only attribute before retrying. Replace all shutil.rmtree() call sites across:

  • amplifier_app_cli/utils/cache_management.py — new rmtree_safe() helper
  • amplifier_app_cli/utils/module_cache.py — module cache clearing (2 sites)
  • amplifier_app_cli/commands/reset.py — reset command directory removal (2 sites)
  • amplifier_app_cli/lib/sources_compat.py — partial install cleanup

The root cause for bundle update failures is in amplifier-foundation/sources/git.py, fixed in the companion PR.

Validation

Tested end-to-end on Windows:

  1. anokye-labs/amplifier-app-cli@pre-fix (unfixed) → [WinError 5] on all 22 modules, all bundles fail
  2. anokye-labs/amplifier-app-cli@main (fixed) → ✓ Cleared 40 cached items, ✓ Update complete — all bundles succeed

Companion fix in amplifier-foundation: microsoft/amplifier-foundation#137

Amplifier added 2 commits March 23, 2026 11:33
…pdate

On Windows, git pack files (.git/objects/pack/*.idx, *.pack) are created
read-only. Python's shutil.rmtree() fails on these with [WinError 5] Access
is denied when the update command tries to clear cached module/bundle dirs.

Add rmtree_safe() helper in cache_management.py that installs an onexc
handler (Python 3.12+) or onerror handler (older) to strip the read-only
attribute before retrying deletion. Replace all shutil.rmtree() call sites
in module_cache.py, reset.py, and sources_compat.py with rmtree_safe().

Also add a-amplifier script entrypoint and wire amplifier-foundation source
to anokye-labs/amplifier-foundation@main for isolated testing.

Fixes: amplifier update failing on Windows with [WinError 5] Access is denied
on .git/objects/pack/*.idx files
Remove a-amplifier test entrypoint and revert amplifier-foundation source
back to microsoft/amplifier-foundation@main. These were added for isolated
Windows testing of the WinError 5 fix but should not be included upstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(windows): amplifier update fails with [WinError 5] Access is denied on module cache directories

1 participant