Skip to content

Commit d71fabd

Browse files
rohitashwinclaude
andcommitted
fix(server): preserve tap-qualified Homebrew formula names
Homebrew Cellar/Caskroom paths are keyed by the formula's bare name only ("rack = HOMEBREW_CELLAR/name"), so a tap-qualified formula like "anomalyco/tap/opencode" can never be recovered from the install path. Only override the configured formula with the extracted one when the extracted name actually diverges from the configured formula's basename, so tapped formulas keep their tap qualifier and bare-name formulas still pick up divergent installs like "claude-code@latest". Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent 48bcaa8 commit d71fabd

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎apps/server/src/provider/providerMaintenance.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,31 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
332332
});
333333
});
334334

335+
it("keeps the tap-qualified Homebrew formula when the Cellar path only has the bare name", () => {
336+
expect(
337+
scopedPackageToolUpdate.resolve({
338+
binaryPath: "/opt/homebrew/bin/scoped-package-tool",
339+
resolvedCommandPath: "/opt/homebrew/bin/scoped-package-tool",
340+
realCommandPath: "/opt/homebrew/Cellar/scoped-package-tool/1.0.0/bin/scoped-package-tool",
341+
env: {
342+
PATH: "",
343+
},
344+
}),
345+
).toEqual({
346+
provider: driver("scopedPackageTool"),
347+
packageName: "@example/scoped-package-tool",
348+
update: {
349+
command: "brew upgrade example/tap/scoped-package-tool",
350+
351+
executable: "brew",
352+
353+
args: ["upgrade", "example/tap/scoped-package-tool"],
354+
355+
lockKey: "homebrew",
356+
},
357+
});
358+
});
359+
335360
it("upgrades the actually-installed Homebrew formula, not the definition's default", () => {
336361
expect(
337362
packageToolUpdate.resolve({

‎apps/server/src/provider/providerMaintenance.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,32 @@ function makeVitePlusGlobalProviderMaintenanceCapabilities(
188188
});
189189
}
190190

191+
function homebrewFormulaBasename(formula: string): string {
192+
const segments = formula.split("/");
193+
return segments[segments.length - 1];
194+
}
195+
196+
function resolveHomebrewFormula(
197+
definition: PackageManagedProviderMaintenanceDefinition,
198+
installedFormula: string | null,
199+
): string | null {
200+
if (!installedFormula) {
201+
return definition.homebrewFormula;
202+
}
203+
if (
204+
definition.homebrewFormula &&
205+
homebrewFormulaBasename(definition.homebrewFormula) === installedFormula
206+
) {
207+
return definition.homebrewFormula;
208+
}
209+
return installedFormula;
210+
}
211+
191212
function makeHomebrewProviderMaintenanceCapabilities(
192213
definition: PackageManagedProviderMaintenanceDefinition,
193214
installedFormula?: string | null,
194215
): ProviderMaintenanceCapabilities {
195-
const formula = installedFormula ?? definition.homebrewFormula;
216+
const formula = resolveHomebrewFormula(definition, installedFormula ?? null);
196217
if (!formula) {
197218
return makeManualOnlyProviderMaintenanceCapabilities({
198219
provider: definition.provider,

0 commit comments

Comments
 (0)