Skip to content

bug: update cannot detect Homebrew cask installs on Intel macOS (/usr/local/Caskroom/...) #175

Closed

Description

@blimmer

What happened?

contextbridge update fails to detect that the binary was installed via the Homebrew cask when running on Intel macOS. The user is told to run a manual recovery command even though the binary is in a perfectly standard Homebrew cask location and brew upgrade --cask contextbridge/tap/cli would have worked.

Root cause is in packages/cli/src/updater/UpdaterImpl.ts:22:

const HOMEBREW_MARKERS = [`${sep}Cellar${sep}`, `${sep}opt${sep}homebrew${sep}`, `${sep}linuxbrew${sep}`];

The marker list covers:

  • Cellar — formula installs only; casks don't land here.
  • opt/homebrew — Apple Silicon's brew prefix.
  • linuxbrew — Linux brew.

Homebrew cask payloads live under $(brew --prefix)/Caskroom/<cask>/<version>/.... On Apple Silicon that's /opt/homebrew/Caskroom/..., which coincidentally matches the opt/homebrew marker. On Intel macOS the prefix is /usr/local, so the cask path is /usr/local/Caskroom/... — and none of the three markers match. detectInstallMethod() at packages/cli/src/updater/UpdaterImpl.ts:217 falls through to 'unknown', and update.ts:25 prints the recovery-needed fallback.

The existing detection test matrix at packages/cli/src/updater/UpdaterImpl.test.ts:297-300 only exercises Cellar (formula) layouts on Intel brew, Apple Silicon brew, and linuxbrew. No case covers the Caskroom layout, so the bug is invisible in CI.

contextbridge version

Reproduced against main (current HOMEBREW_MARKERS constant is unchanged on the default branch). Originally surfaced by a user on v0.1.2 upgrading toward v0.7.1, but the same detection code ships in the latest release.

Operating system

macOS

Specifically Intel macOS (arch: "x64"). Apple Silicon is unaffected by accident — /opt/homebrew/Caskroom/... happens to match the opt/homebrew marker. Linux is unaffected because the cask install path doesn't apply there.

Steps to reproduce

  1. On an Intel Mac (arch x64), install the cask: brew install --cask contextbridge/tap/cli. The binary lands at /usr/local/Caskroom/cli/<version>/contextbridge.
  2. When a newer version is available on the tap, run contextbridge update.
  3. Observe the warning and recovery hint instead of an automatic brew upgrade --cask run.

What did you expect to happen?

contextbridge update should detect the install as Homebrew and shell out to brew upgrade --cask contextbridge/tap/cli (or ...cli@alpha on the alpha channel), the same path that already works on Apple Silicon cask installs and Intel/Apple Silicon formula installs.

What actually happened?

detectInstallMethod() returned 'unknown', so performUpdate() returned a recovery-needed result. The CLI logged update: could not detect install method at warn level and printed the manual recovery commands, requiring the user to copy/paste a brew or curl command.

Relevant logs or stack trace

A new version is available: v0.7.1 (you're on v0.1.2).
WARN: update: could not detect install method
  execPath: "/usr/local/Caskroom/cli/0.1.2/contextbridge"
  realPath: "/usr/local/Caskroom/cli/0.1.2/contextbridge"
  platform: "darwin"
  arch: "x64"
contextbridge couldn't detect how the binary at /usr/local/Caskroom/cli/0.1.2/contextbridge was installed. Run one of the commands below to upgrade manually, or reinstall into a supported location.

brew upgrade --cask contextbridge/tap/cli
/bin/sh -c "$(curl -fsSL https://downloads.contextbridge.ai/cli/install.sh)"

Anything else

Suggested fix: add ${sep}Caskroom${sep} to HOMEBREW_MARKERS. It covers the Intel cask layout (/usr/local/Caskroom/...) and is harmless on Apple Silicon (/opt/homebrew/Caskroom/... — still detected, just by a different marker first). Also extend the parameterized test at packages/cli/src/updater/UpdaterImpl.test.ts:297 with cask-layout paths for both Intel and Apple Silicon so this case stays covered.

Activity

  1. added
    bug
    on May 19, 2026
  2. added a commit that references this issue on May 19, 2026
    1edd638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions