From 345dccb3ea63ac6aa0d9c7d17132bc5e614e545f Mon Sep 17 00:00:00 2001 From: Pjotr Date: Mon, 16 Nov 2026 10:07:32 +0000 Subject: install.sh: replace an existing root instead of failing on it The first version worked exactly once. guix build --root cannot replace a root that already exists -- it answers guix build: error: failed to create GC root '.../root': File exists -- so the second run, which is the normal case, died before building. The script now removes the old symlink first and refuses to touch anything that is not a symlink, since a directory at that path is someone else's mistake. Verified by running it three times in a row against a tree that changed between runs (adding this file moves the store path, which is what makes the root worth having). --- scripts/install.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts') diff --git a/scripts/install.sh b/scripts/install.sh index 0bc8a8f..595fd8c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -33,6 +33,15 @@ command -v guix >/dev/null 2>&1 || { } mkdir -p "$(dirname "$ROOT")" +# guix build --root cannot replace an existing root: it answers "failed to create +# GC root ...: File exists". Drop the old symlink first, and refuse to touch +# anything that is not one -- a directory here is somebody's mistake, not ours. +if [ -L "$ROOT" ]; then + rm -f "$ROOT" +elif [ -e "$ROOT" ]; then + echo "install.sh: $ROOT exists and is not a symlink; remove it or set AI_MEMORY_ROOT" >&2 + exit 1 +fi # Build from this checkout (guix.scm's source is a local-file, so the store path # is a function of the tree) and root it in one step. store=$(cd "$here" && guix build -f guix.scm --root="$ROOT") -- cgit 1.4.1