Skip to content

Prevent luca install from running in the home directory#72

Merged
albertodebortoli merged 2 commits intomainfrom
fix/install-from-home-dir
Apr 14, 2026
Merged

Prevent luca install from running in the home directory#72
albertodebortoli merged 2 commits intomainfrom
fix/install-from-home-dir

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

Pull Request Title

Prevent luca install from running in the home directory

Description

  • When luca install is run from ~, symlinksFolder (.luca/tools/ relative to CWD) resolves to ~/.luca/tools/ — the same path as the global tool cache (toolsFolder). This causes symlink creation to conflict with versioned tool directories, corrupting the cache structure.
  • Fix: throw InstallerError.runningFromHomeDirectory with a clear message before any installation begins when CWD equals the home directory.
  • No related issue.

Type of Change

  • Bug fix

How Has This Been Tested?

  • Added / updated unit tests
  • Manually tested locally (describe)
  • Tested on macOS (arch: arm64)

Added parameterized test test_install_fromHomeDirectory_throwsError covering both quiet: true and quiet: false paths. Verified that Installer.InstallerError.runningFromHomeDirectory is thrown and the error message is correct.

swift test --filter InstallerTests

Checklist

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

Breaking Changes?

  • No

Additional Notes

The check uses a plain string comparison (fileManager.currentDirectoryPath != fileManager.homeDirectoryForCurrentUser.path) rather than URL-based comparison to avoid macOS symlink resolution (/var/private/var) causing false negatives in tests.

Running `luca install` from `~` causes `symlinksFolder` to resolve to the same path as `toolsFolder` (~/.luca/tools/), corrupting the tool cache. Throw a clear error when the current directory is the home directory.
@albertodebortoli albertodebortoli added the bugfix Something isn't working label Apr 14, 2026
@albertodebortoli albertodebortoli added this to the 0.16.0 milestone Apr 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 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 14, 2026 17:59
@albertodebortoli albertodebortoli merged commit 717748b into main Apr 14, 2026
3 checks passed
@albertodebortoli albertodebortoli deleted the fix/install-from-home-dir branch April 14, 2026 17:59
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