Skip to content

Fix unlink command failing on dangling symlinks#60

Merged
albertodebortoli merged 1 commit intomainfrom
fix-unlink-dangling-symlink
Apr 10, 2026
Merged

Fix unlink command failing on dangling symlinks#60
albertodebortoli merged 1 commit intomainfrom
fix-unlink-dangling-symlink

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

Description

  • When a tool was previously uninstalled, luca unlink <tool> failed with Error: Symlink '<tool>' not found. because fileExists follows symlinks and returns false for dangling ones.
  • Switched to attributesOfItem which does not follow symlinks, so the unlinker can detect and remove dangling symlinks.
  • When a dangling symlink is removed, the user is informed that the tool is not installed via an additional info line.
  • If no symlink exists at all, the command still exits with a non-zero code.

Type of Change

  • Bug fix

How Has This Been Tested?

  • Added / updated unit tests
  • Manually tested locally

New test unlink_danglingSymlink_removesSymlink creates a real dangling symlink and verifies it gets cleaned up. Existing unlink_symlinkNotFound test confirms the error is still thrown when no symlink exists.

Checklist

  • Swift code builds locally (swift build)
  • Tests pass locally (swift test)
  • Code style / formatting respected
  • Documentation updated (README / comments)

Breaking Changes?

  • No

fileExists follows symlinks, so it returned false for dangling symlinks
left behind after a tool was uninstalled. Switch to attributesOfItem
which does not follow symlinks, allowing the unlinker to detect and
remove dangling symlinks while informing the user that the underlying
tool is not installed.
@albertodebortoli albertodebortoli added the bugfix Something isn't working label Apr 10, 2026
@albertodebortoli albertodebortoli added this to the 0.14.0 milestone Apr 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@albertodebortoli albertodebortoli marked this pull request as ready for review April 10, 2026 14:08
@albertodebortoli albertodebortoli merged commit 1e749dd into main Apr 10, 2026
3 checks passed
@albertodebortoli albertodebortoli deleted the fix-unlink-dangling-symlink branch April 10, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant