Skip to content

Harden symlink cleanup error handling - #3

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1784363619-improve-error-handling
Open

Harden symlink cleanup error handling#3
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1784363619-improve-error-handling

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

The only executable code in this repo is install.sh and uninstall.sh; the rest is markdown skills. Two error-handling weaknesses in those scripts are fixed.

1. Legacy cleanup aborted the whole run on an unresolvable symlink. remove_link_if_target resolves a relative link target by cd-ing into the target's parent dir. If that dir is missing (e.g. an unrelated broken symlink in ~/.claude/skills), the cd fails under set -euo pipefail and the entire install/uninstall aborts with a cryptic cd: No such file or directory, skipping all remaining cleanup. Now the resolution is guarded and an unresolvable link is skipped with a clear warning:

if ! resolved_dir="$(cd "$(dirname "$link_path")" && cd "$(dirname "$link_target")" 2>/dev/null && pwd -P)"; then
  echo "Warning: could not resolve symlink target for '$link_path'; skipping." >&2
  return 0
fi

2. rmdir swallowed every error. rmdir "$DIR" 2>/dev/null || true (uninstall) discarded all failures, including real ones (permissions), not just the expected non-empty case. Replaced with an explicit empty check so genuine failures still propagate via set -e:

for skills_dir in "$CLAUDE_SKILLS_DIR" "$CODEX_SKILLS_DIR"; do
  if [ -d "$skills_dir" ] && [ -z "$(ls -A "$skills_dir")" ]; then
    rmdir "$skills_dir"
  fi
done

Applied the resolution guard to both scripts (the helper is duplicated).

Testing

  • Reproduced the pre-fix abort: a broken relative symlink made the old resolver exit 1 mid-run.
  • Post-fix, install + uninstall complete (exit 0) with an unrelated broken symlink present, leave it untouched, and correctly remove the skills dir only when empty. Idempotent re-install verified. bash -n clean on both scripts.

Link to Devin session: https://app.devin.ai/sessions/c58c81d23fc54b15bd512e7da87bdb36
Requested by: @sidwood

Legacy symlink cleanup resolved relative link targets by cd-ing into the
target's parent directory. When that directory was missing (an unrelated
broken symlink in the skills dir), the cd failed under `set -e` and
aborted the entire install/uninstall, leaving the rest of the run
unfinished with only a cryptic cd error.

- Resolve relative targets inside a guarded conditional so an
  unresolvable link is skipped with a clear warning instead of aborting.

- Replace `rmdir ... 2>/dev/null || true`, which swallowed every failure,
  with an explicit empty-directory check so a genuine rmdir error (e.g.
  permissions) still surfaces while non-empty directories are left alone.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@sidwood sidwood self-assigned this Jul 18, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant