diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-16 10:07:32 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-16 10:07:32 +0000 |
| commit | 345dccb3ea63ac6aa0d9c7d17132bc5e614e545f (patch) | |
| tree | 45f8b52d1104e8d145561fe2d5e831f816eeadf5 /scripts | |
| parent | 744278e9881db1b9cd544fb8061bb616b9020886 (diff) | |
| download | ai-memory-345dccb3ea63ac6aa0d9c7d17132bc5e614e545f.tar.gz | |
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).
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/install.sh | 9 |
1 files changed, 9 insertions, 0 deletions
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") |
