Skip to content

Commit 0d198da

Browse files
committed
fix(cli): detect Homebrew cask installs on Intel macOS
The `update` command's install-method detection only matched `Cellar` (formula installs), the Apple Silicon brew prefix (`opt/homebrew`), and linuxbrew. Intel-Mac cask installs land in `/usr/local/Caskroom/...`, which none of those markers cover, so detection fell through to `unknown` and forced users into the manual recovery path. Apple Silicon cask installs (`/opt/homebrew/Caskroom/...`) worked only by coincidence — the `opt/homebrew` marker happened to match. Add an explicit `Caskroom` marker so both arches detect cleanly, and extend the parameterized detection test with cask layouts on Intel and Apple Silicon. Closes #175.
1 parent cb401a4 commit 0d198da

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎packages/cli/src/updater/UpdaterImpl.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,11 @@ describe('UpdaterImpl.performUpdate', () => {
294294
});
295295

296296
it.each([
297-
['/opt/homebrew/Cellar/contextbridge/0.1.0/bin/contextbridge', 'Apple Silicon brew'],
298-
['/usr/local/Cellar/contextbridge/0.1.0/bin/contextbridge', 'Intel brew'],
299-
['/home/linuxbrew/.linuxbrew/Cellar/contextbridge/0.1.0/bin/contextbridge', 'linuxbrew'],
297+
['/opt/homebrew/Cellar/contextbridge/0.1.0/bin/contextbridge', 'Apple Silicon brew formula'],
298+
['/usr/local/Cellar/contextbridge/0.1.0/bin/contextbridge', 'Intel brew formula'],
299+
['/home/linuxbrew/.linuxbrew/Cellar/contextbridge/0.1.0/bin/contextbridge', 'linuxbrew formula'],
300+
['/opt/homebrew/Caskroom/cli/0.1.0/contextbridge', 'Apple Silicon brew cask'],
301+
['/usr/local/Caskroom/cli/0.1.0/contextbridge', 'Intel brew cask'],
300302
])('detects %s as homebrew (%s layout)', async (execPath) => {
301303
const commandRunner = new FakeCommandRunner();
302304
commandRunner.onAny().resolves();

‎packages/cli/src/updater/UpdaterImpl.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ const CACHE_FILE_NAME = 'update-check.json';
1919
const CASK_BASE = 'https://raw.githubusercontent.com/contextbridge/homebrew-tap/main/Casks';
2020
const FETCH_TIMEOUT_MS = 2_000;
2121
const INSTALL_SH_URL = 'https://downloads.contextbridge.ai/cli/install.sh';
22-
const HOMEBREW_MARKERS = [`${sep}Cellar${sep}`, `${sep}opt${sep}homebrew${sep}`, `${sep}linuxbrew${sep}`];
22+
const HOMEBREW_MARKERS = [
23+
`${sep}Cellar${sep}`,
24+
`${sep}Caskroom${sep}`,
25+
`${sep}opt${sep}homebrew${sep}`,
26+
`${sep}linuxbrew${sep}`,
27+
];
2328

2429
export type Duration = ReturnType<typeof Temporal.Duration.from>;
2530

0 commit comments

Comments
 (0)