Skip to content

Commit 0c2ee41

Browse files
chapterjasonclaude
andcommitted
home-persist: auto-repair legacy nested symlink artifact (1.2.1)
Systems affected by the pre-1.2.0 bug still have a stale symlink inside the home directory (e.g. $HOME/.claude/.claude → /mnt/home-persist/.claude). Detect it before the merge — readlink -f match on $target — and drop it, so the subsequent cp -an doesn't copy it into the volume as a self-loop and the ln -sfn below replaces the directory cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4eb11cd commit 0c2ee41

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/home-persist/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "home-persist",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"name": "home-persist",
55
"description": "Symlinks selected paths under $HOME into a per-owner persistence volume mounted at /mnt/home-persist. Features and users declare paths via JSON manifests in /etc/devcontainer-persist.d/, and an onCreateCommand materializes the symlinks on every create. Requires the consumer to bind-mount a persistent source to /mnt/home-persist in devcontainer.json.",
66
"documentationURL": "https://github.com/SoureCode/devcontainer-features/tree/master/src/home-persist",

src/home-persist/resolve.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ for mf in "${manifests[@]}"; do
7474
mkdir -p "$(dirname "$target")" "$(dirname "$link")"
7575

7676
if [ -e "$link" ] && [ ! -L "$link" ]; then
77+
# Auto-repair the <1.2.0 artifact: if $link is still a real directory
78+
# and contains a dangling-style symlink named after rel's basename
79+
# pointing at $target, that's the nested symlink the old code produced
80+
# (e.g. $HOME/.claude/.claude → /mnt/home-persist/.claude). Drop it
81+
# before the merge so it isn't copied into the volume as a self-loop.
82+
stale="$link/$(basename "$rel")"
83+
if [ -L "$stale" ]; then
84+
stale_resolved="$(readlink -f "$stale" 2>/dev/null || true)"
85+
target_resolved="$(readlink -f "$target" 2>/dev/null || true)"
86+
if [ -n "$stale_resolved" ] && [ "$stale_resolved" = "$target_resolved" ]; then
87+
log "repairing legacy nested symlink $stale"
88+
rm -f "$stale"
89+
fi
90+
fi
91+
7792
if [ ! -e "$target" ]; then
7893
mv "$link" "$target"
7994
elif [ -d "$link" ] && [ -d "$target" ]; then

0 commit comments

Comments
 (0)