fix(windows): handle read-only git pack files causing WinError 5 on amplifier update#152
Open
hoopsomuah wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(windows): handle read-only git pack files causing WinError 5 on amplifier update#152hoopsomuah wants to merge 2 commits intomicrosoft:mainfrom
hoopsomuah wants to merge 2 commits intomicrosoft:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes microsoft/amplifier#241
Problem
On Windows,
amplifier updatefails with[WinError 5] Access is deniedwhen clearing cached module and bundle directories. Git pack files (.git/objects/pack/*.idx) are created read-only on Windows, andshutil.rmtree()doesn't handle this.Example output:
Fix
Add
rmtree_safe()helper inamplifier_app_cli/utils/cache_management.pywith an error handler that strips the read-only attribute before retrying. Replace allshutil.rmtree()call sites across:amplifier_app_cli/utils/cache_management.py— newrmtree_safe()helperamplifier_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 cleanupThe 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:
anokye-labs/amplifier-app-cli@pre-fix(unfixed) →[WinError 5]on all 22 modules, all bundles failanokye-labs/amplifier-app-cli@main(fixed) →✓ Cleared 40 cached items,✓ Update complete— all bundles succeedCompanion fix in
amplifier-foundation: microsoft/amplifier-foundation#137