From cff860499e636aa8e6dbaaf339f8f3cf37bdc020 Mon Sep 17 00:00:00 2001 From: xavix-yo Date: Mon, 20 Jul 2026 18:29:53 +0100 Subject: [PATCH] Fix uninstall.sh: retry with sudo when rm -rf fails on Docker-owned files homes/ directory can contain files owned by other UIDs (root, etc.) because Docker containers run as different users. Normal rm -rf fails with Permission denied. Now falls back to sudo rm -rf automatically. --- SKALD.md | 6 ++++++ uninstall.sh | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SKALD.md b/SKALD.md index bc4b0dc..9efb9a6 100644 --- a/SKALD.md +++ b/SKALD.md @@ -48,6 +48,12 @@ curl -fsSL https://builds.skaldagent.net/install.sh | bash Or, after installation: `~/.local/share/skald-circle/uninstall.sh` +## Bug fix: uninstall.sh fails on Docker-owned files in homes/ ✅ + +**Problem**: `uninstall.sh` runs `rm -rf "$INSTALL_DIR"` as the normal user, but `homes/` contains files created by Docker containers running under different UIDs (often root). The removal fails with "Permission denied" on those files, leaving a broken install behind. + +**Fix**: if `rm -rf` fails (non-zero exit), the script retries with `sudo rm -rf`. If even sudo fails, it prints an error message and exits non-zero so the user knows manual cleanup is needed. + ### From source ```sh diff --git a/uninstall.sh b/uninstall.sh index 87c3b15..ee3391a 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -97,7 +97,16 @@ esac # ── Remove installation directory ───────────────────────────────────────────── if [ -d "$INSTALL_DIR" ]; then info "🗑️ Removing installation directory …" - rm -rf "$INSTALL_DIR" + rm -rf "$INSTALL_DIR" 2>/dev/null || { + warn "Some files are owned by other users (e.g. from Docker sandboxes)." + info "🔐 Retrying with sudo …" + sudo rm -rf "$INSTALL_DIR" + } + if [ -d "$INSTALL_DIR" ]; then + err "Failed to remove ${INSTALL_DIR} even with sudo." + err "You may need to manually remove it." + exit 1 + fi info "✔ Removed ${INSTALL_DIR}" else warn "Installation directory not found: ${INSTALL_DIR}"