Skip to content

fix: resolve formula aliases before tracking installed packages#20

Open
jerryjrxie wants to merge 2 commits intoopenbootdotdev:mainfrom
jerryjrxie:fix/formula-aliases
Open

fix: resolve formula aliases before tracking installed packages#20
jerryjrxie wants to merge 2 commits intoopenbootdotdev:mainfrom
jerryjrxie:fix/formula-aliases

Conversation

@jerryjrxie
Copy link
Copy Markdown
Contributor

Summary

Fixes an issue where packages with formula aliases (like postgresqlpostgresql@18) were being reinstalled on every run because the state tracking didn't match the actual installed names.

Problem

Homebrew has formula aliases where the requested name differs from the actual installed name:

  • postgresql → installs as postgresql@18
  • kubectl → installs as kubernetes-cli

The state file tracked the alias name ("postgresql") but brew list returns the actual name ("postgresql@18"), so they never matched during state reconciliation. This caused packages to be reinstalled every time openboot ran.

Solution

  • Added ResolveFormulaName() function that uses brew info --json to resolve aliases to canonical names
  • Updated all package tracking in InstallWithProgress() to use resolved names:
    • When checking if already installed
    • When tracking newly installed packages
    • When tracking failed packages for retry
  • Handles both CLI formulae and casks

Testing

  • Fix verified: postgresql and kubectl now resolve to their canonical names before tracking
  • go vet passes
  • Changes are minimal and focused on the tracking issue

Related

This complements PR #18 which fixed GUI apps being skipped. Both issues affected package tracking but for different reasons.

Homebrew has formula aliases where the requested name differs from the
actual installed name. Examples:
- postgresql → installs as postgresql@18
- kubectl → installs as kubernetes-cli

This caused packages to be reinstalled on every run because the state
file tracked the alias name (e.g., postgresql) but brew list returns
the actual name (e.g., postgresql@18), so they never matched during
reconciliation.

Fix:
- Added ResolveFormulaName() function to resolve aliases using brew info --json
- Updated all package tracking to use resolved names
- Handles both CLI packages and casks

Closes openbootdotdev#17 (formula alias tracking issue)
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

🎉 This is your first PR to OpenBoot — welcome!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

Copy link
Copy Markdown
Collaborator

@fullstackjam fullstackjam left a comment

Choose a reason for hiding this comment

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

Good instinct — alias resolution is a real problem. A few implementation issues to address:

[HIGH] Performance: N serialized brew info subprocess calls
ResolveFormulaName is called once per package in the pre-check loop and again in the post-install loop — that is 2N synchronous subprocesses. brew info --json accepts multiple arguments, so this should be batched into a single call at the start and the results cached in a map.

[HIGH] Retry path is not fixed
The fix only covers the first-attempt success path. When a formula fails and succeeds on retry, it is still tracked using the original alias name. Please apply the same resolution logic in the retry block.

[MEDIUM] Do not apply formula alias resolution to casks
Casks do not have an alias system, and their JSON schema differs from formulae — the name field has a different meaning. Calling ResolveFormulaName on a cask silently no-ops due to the schema mismatch, but wastes a subprocess call per cask. Skip resolution for casks entirely.

[LOW] No tests
Given the number of edge cases here (alias resolution, retry path, cask vs formula), some unit test coverage would go a long way.

@fullstackjam fullstackjam dismissed their stale review March 30, 2026 11:52

Dismissing — will re-review after further discussion

Copy link
Copy Markdown
Collaborator

@fullstackjam fullstackjam left a comment

Choose a reason for hiding this comment

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

Good instinct — alias resolution is a real problem. A few implementation issues to address:

[HIGH] Performance: N serialized brew info subprocess calls
ResolveFormulaName is called once per package in the pre-check loop and again in the post-install loop — that's 2N synchronous subprocesses. brew info --json accepts multiple arguments, so this should be batched into a single call at the start and the results cached in a map.

[HIGH] Retry path is not fixed
The fix only covers the first-attempt success path. When a formula fails and succeeds on retry, it's still tracked using the original alias name. Please apply the same resolution logic in the retry block.

[MEDIUM] Don't apply formula alias resolution to casks
Casks don't have an alias system, and their JSON schema differs from formulae — the name field has a different meaning. Calling ResolveFormulaName on a cask silently no-ops due to the schema mismatch, but wastes a subprocess call per cask. Skip resolution for casks entirely.

[LOW] No tests
Given the number of edge cases here (alias resolution, retry path, cask vs formula), some unit test coverage would go a long way.

@fullstackjam fullstackjam dismissed their stale review March 30, 2026 11:58

Duplicate — see earlier review.

@fullstackjam fullstackjam added brew Homebrew related installer Package installation logic labels Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

brew Homebrew related installer Package installation logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants