From d6261de1e721d6f6e1a5dd9a17e4160d6bd5804b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 20 Jul 2026 02:39:07 +0000 Subject: [PATCH] Re-clone bootstrap.sh's target directory when the existing copy is broken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an existing ~/ubuntu-post-install checkout has a broken/SSH-only origin remote, `git pull --ff-only` fails and the script fell through to "continuing with existing version" — even when that existing copy is missing setup.sh entirely, guaranteeing a crash right after. Now checks for setup.sh post-pull and wipes + re-clones over HTTPS (no SSH key needed) if it's still missing. --- bootstrap.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 0d0f7b3..d12e6e0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -87,6 +87,21 @@ else fi fi +# The pull-failed fallback above assumes the existing checkout is at least +# usable — it isn't always (e.g. a stale/broken .git dir, an origin remote +# pointed at SSH with no key available under sudo, an interrupted first +# clone). Rather than hand the user a guaranteed "setup.sh: No such file or +# directory" crash, treat a missing setup.sh as "this copy is unusable" and +# re-clone fresh over HTTPS (which doesn't need any SSH key at all). +if [ ! -f "$DEST/setup.sh" ]; then + echo " Existing copy at $DEST looks incomplete or broken — re-cloning fresh..." + rm -rf "$DEST" + git clone "$CLONE_URL" "$DEST" + if [ -n "$PAT" ]; then + git -C "$DEST" remote set-url origin "$REPO_URL" + fi +fi + echo "" echo " Launching setup..." echo ""