Skip to content

Fix: reinstall creates symlink to wrong binary when binaryPath is set#40

Merged
albertodebortoli merged 1 commit intomainfrom
fix/reinstall-symlinks-wrong-binary-when-binarypath-is-configured
Mar 17, 2026
Merged

Fix: reinstall creates symlink to wrong binary when binaryPath is set#40
albertodebortoli merged 1 commit intomainfrom
fix/reinstall-symlinks-wrong-binary-when-binarypath-is-configured

Conversation

@victor-sarda
Copy link
Copy Markdown
Collaborator

Description

When a tool was already installed, Luca would ignore the configured binaryPath and always run BinaryFinder to decide which binary to symlink. BinaryFinder walks the tool directory and returns the first file with Mach-O or ELF magic bytes which is not necessarily the intended entry point.

This breaks any tool that ships with a shell-script launcher as its entry point alongside other real binaries in the archive (e.g. a bundled JRE, debug helpers, etc.). On every luca install, the symlink in .luca/tools/ would be recreated, pointing to whichever binary was found first, rather than the one specified in the Lucafile.

Root cause: reinstall (the code path taken when isToolInstalled returns true) unconditionally called binaryFinder.findBinary(), while installArchive (the fresh-install path) already correctly honoured binaryPath first and only fell back to BinaryFinder when no binaryPath was set.

Fix: apply the same guard to reinstall:

let binaryPath: String = try {
    if let binaryPath = tool.binaryPath { return binaryPath }
    return try binaryFinder.findBinary(atPath: installationDestination.path)
}()

Type of Change

  • Feature
  • Bug fix
  • Maintenance / Refactor
  • Documentation
  • CI / Tooling
  • Other (specify)

How Has This Been Tested?

Describe the testing strategy and commands executed.

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

Checklist

  • Swift code builds locally (swift build)
  • Tests pass locally (swift test)
  • Code style / formatting respected
  • Documentation updated (README / comments)
  • Version / tag alignment considered (if release related)
  • PR title follows conventional style (optional)

CI Considerations

  • Affects build time notably
  • Requires new secrets / env vars
  • Alters release process

Breaking Changes?

  • No
  • Yes (describe impact and migration path)

@albertodebortoli albertodebortoli added the bugfix Something isn't working label Mar 17, 2026
Copy link
Copy Markdown
Member

@albertodebortoli albertodebortoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! 🚀

@albertodebortoli albertodebortoli merged commit dda5cfb into main Mar 17, 2026
2 checks passed
@albertodebortoli albertodebortoli deleted the fix/reinstall-symlinks-wrong-binary-when-binarypath-is-configured branch March 17, 2026 12:04
@albertodebortoli albertodebortoli added this to the 0.11.0 milestone Mar 23, 2026
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.

2 participants