Skip to content

fix: use os.RemoveAll for non-empty directories when --force is set#9

Merged
gzb1128 merged 1 commit into
mainfrom
fix/force-overwrite-directory
Jun 2, 2026
Merged

fix: use os.RemoveAll for non-empty directories when --force is set#9
gzb1128 merged 1 commit into
mainfrom
fix/force-overwrite-directory

Conversation

@gzb1128

@gzb1128 gzb1128 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • When --force is set and the existing path is a real directory (not a symlink), os.Remove silently fails because it cannot remove non-empty directories, causing the force flag to have no effect
  • Fixed by using os.RemoveAll when the existing path is a directory, in both linkComponentDir and linkComponentPaths

Root Cause

~/.agents/skills/loopfix was a real directory (installed by another tool/plugin, not a symlink). The linker used os.Remove to clear existing paths during force-overwrite, but os.Remove only works on files, empty directories, and symlinks.

Test Plan

  • All existing tests pass (go test ./...)
  • Manually verify: install a plugin with --force when a skill directory already exists at the target path

When --force is set and the existing path is a real directory (not a symlink),
os.Remove fails because it cannot remove non-empty directories. This causes
the force flag to silently skip the path. Use os.RemoveAll instead when the
existing path is a directory.
@gzb1128 gzb1128 merged commit 1348ca9 into main Jun 2, 2026
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