fix(upgrade): only route brew-managed tools to brew#900
Conversation
effectiveMethod routed every tool to `brew upgrade <tool>` whenever the platform package manager was detected as Homebrew. On Linux with Linuxbrew present, tools installed via install.sh into ~/.local/bin are not brew formulae, so the upgrade failed with "Error: <tap>/<tool> not installed". Guard the brew branch with isBrewManaged(): resolve the tool's binary (PATH + symlinks) and only choose brew when it lives under a Homebrew prefix (a /Cellar/ path segment, $HOMEBREW_PREFIX, /opt/homebrew or /home/linuxbrew/.linuxbrew). Otherwise fall through to the tool's declared InstallMethod (binary download for gentle-ai/engram, script for gga). Platform detection is left unchanged on purpose: reporting PackageManager as "brew" is still correct for dependency install hints; the per-tool guard is the minimal, lower-risk fix for the upgrade path. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesConditional Homebrew Upgrade Routing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Thanks for taking this on. I’m closing this in favor of #904 because path-based detection is more likely to misclassify casks, aliases, or non-standard Homebrew prefixes. The lower-risk contract here is to ask Homebrew directly whether it manages the tool. This is a duplicate closure, not a rejection of the bug fix. |
🔗 Linked Issue
Closes #186
🏷️ PR Type
type:bug— Bug fix (non-breaking change that fixes an issue)📝 Summary
effectiveMethod()routed every tool tobrew upgrade <tool>whenever the detected platform package manager wasbrew. On Linux with Linuxbrew installed for unrelated packages, tools installed viainstall.shinto~/.local/binare not brew formulae, so the upgrade failed withError: <tap>/<tool> not installed.isBrewManaged()check: the brew strategy is only chosen when the tool's binary actually lives under a Homebrew prefix; otherwise it falls through to the tool's declaredInstallMethod(binary download forgentle-ai/engram, script forgga).internal/system/detect.go) is intentionally left unchanged — reportingPackageManager: "brew"is still correct for dependency install hints; the per-tool guard is the minimal, lower-risk fix scoped to the upgrade path.📂 Changes
internal/update/upgrade/executor.goeffectiveMethodwithisBrewManaged(); addbrewBinaryResolver(testable),pathUnderBrewPrefix,brewPrefixes,containsPathSegmenthelpers.internal/update/upgrade/strategy_test.goTestEffectiveMethodwith abrewManagedaxis + regression cases (brew present but tool not brew-managed → declared method); addTestPathUnderBrewPrefix,TestPathUnderBrewPrefixHonorsEnv,TestIsBrewManagedFalseWhenNotOnPath.🧪 Test Plan
Unit Tests
go test ./...go test ./...)cd e2e && ./docker-test.sh)Manual verification on the affected environment (Linux, Linuxbrew at
/home/linuxbrew/.linuxbrew, tools in~/.local/bin):effectiveMethodnow resolvesgentle-ai→binary,engram→binary,gga→script(previously allbrew).✅ Contributor Checklist
status:approvedtype:*label to this PRgo test ./...)cd e2e && ./docker-test.sh)Co-Authored-Bytrailers💬 Notes for Reviewers
I don't have triage permission on this repo, so I couldn't self-apply the
type:buglabel — please add it so theCheck PR Has type:* Labeljob passes. The brew-managed detection is path-based (Cellar/prefix) rather thanbrew list; happy to switch tobrew list --versionsif you'd prefer an authoritative check over an offline one.Summary by CodeRabbit