From 98b80532892a912d5a678ced9f03873c7f1e0da9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 05:21:00 +0000 Subject: [PATCH] fix(devx): prune stale objectui worktree registrations before build-console.sh adds one (#14177) Resolution mode 2 (sibling `../objectui` checkout) creates a git worktree under this repo's `.cache/`, registered in the SHARED objectui/.git. The documented cleanup (`rm -rf` on the framework worktree, or the script's own `worktree remove --force || rm -rf` fallback) deletes that directory without ever telling objectui, so the registration survives as `prunable`. The next `worktree add` at the same path then dies with exit 128 "already registered worktree" -- which reads like a lock or git fault, not a leftover. Run `git -C SOURCE_ROOT worktree prune` immediately before the `worktree add` that would trip over a stranded registration. Safe by construction: prune only drops registrations whose directory is already gone. Option 2 (an exit trap removing the script's own worktree) is skipped: the script deliberately reuses BUILD_ROOT across runs when the pin already matches (for the CI console-dist cache), and a trap firing on every exit would remove it unconditionally and defeat that reuse. --- scripts/build-console.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/build-console.sh b/scripts/build-console.sh index 6be4b62b2b..efc8d24e2d 100755 --- a/scripts/build-console.sh +++ b/scripts/build-console.sh @@ -86,6 +86,16 @@ if [[ -n "$SOURCE_ROOT" ]]; then fi fi if [[ ! -d "$BUILD_ROOT" ]]; then + # Prune stale worktree registrations before adding. Registrations live in + # the SHARED objectui/.git — nothing on the framework side touches them, + # so if a previous run's directory was removed without going through + # `worktree remove` (the force-remove fallback above hitting `rm -rf`, or + # an external `rm -rf .cache/objectui-*` cleanup), the registration + # survives as `prunable` and the next `worktree add` at this same path + # dies with exit 128 "already registered worktree". `prune` only drops + # registrations whose directory is already gone, so it's safe here + # unconditionally. + git -C "$SOURCE_ROOT" worktree prune git -C "$SOURCE_ROOT" worktree add --detach "$BUILD_ROOT" "$PINNED_SHA" fi else