From 985545dc34d967d53806e58a3225999cf99f53af Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Sun, 25 Jan 2026 19:31:54 -0800 Subject: [PATCH] fix: add --force flag to uv cache clean to prevent deadlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `amplifier reset` command was hanging indefinitely while cleaning the UV cache because `uv cache clean` without `--force` waits for an exclusive lock on the cache directory. Since amplifier itself runs as a uv-installed tool, the cache is always "in use" when running `amplifier reset`, causing an unresolvable deadlock. Changes: - Added `--force` flag to bypass the in-use check (per uv's docs) - Added a 60-second timeout as a safeguard - Added handling for `subprocess.TimeoutExpired` exception - Updated docstring to explain why `--force` is required 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com> --- amplifier_app_cli/commands/reset.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/amplifier_app_cli/commands/reset.py b/amplifier_app_cli/commands/reset.py index f9e295ca..8ec1110d 100644 --- a/amplifier_app_cli/commands/reset.py +++ b/amplifier_app_cli/commands/reset.py @@ -141,16 +141,29 @@ def _show_plan( def _clean_uv_cache(dry_run: bool = False) -> bool: - """Run 'uv cache clean'.""" + """Run 'uv cache clean --force'. + + The --force flag is required because amplifier itself runs as a uv-installed tool. + Without --force, uv cache clean waits indefinitely for an exclusive lock that + can never be acquired while the current process is running. + """ console.print("[bold]>>>[/bold] Cleaning UV cache...") if dry_run: - console.print(" [dim][dry-run] Would run: uv cache clean[/dim]") + console.print(" [dim][dry-run] Would run: uv cache clean --force[/dim]") return True try: - subprocess.run(["uv", "cache", "clean"], check=True, capture_output=True) + subprocess.run( + ["uv", "cache", "clean", "--force"], + check=True, + capture_output=True, + timeout=60, # Safeguard timeout + ) return True + except subprocess.TimeoutExpired: + console.print("[yellow]Warning:[/yellow] UV cache clean timed out") + return False except subprocess.CalledProcessError as e: console.print(f"[yellow]Warning:[/yellow] Failed to clean UV cache: {e}") return False