Skip to content

Commit 1adc121

Browse files
sbryngelsonclaude
andcommitted
Fix rm -rf following build symlink into shared cache
rm -rf on a symlink follows it and deletes the target's contents, which fails when another runner is using the shared cache directory. Use unlink for symlinks, rm -rf only for real directories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 09920e7 commit 1adc121

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/scripts/setup-build-cache.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ echo " Cache dir: $_cache_dir"
2525

2626
# Replace any existing build/ (real dir or stale symlink) with a symlink
2727
# to our runner-specific cache directory.
28-
if [ -e "build" ] || [ -L "build" ]; then
28+
# Use unlink for symlinks to avoid rm -rf following the link and deleting
29+
# the shared cache contents (which another runner may be using).
30+
if [ -L "build" ]; then
31+
unlink "build"
32+
elif [ -e "build" ]; then
2933
rm -rf "build"
3034
fi
3135

0 commit comments

Comments
 (0)