#1557·codeburn

Menubar CLI update runs brew upgrade for npm installs under Homebrew's Node prefix

Author: ShunmeiChoCreated Sep 25, 2026Updated Sep 28, 2026
Labelsbugarea: menubar

Summary

On macOS, when Node comes from Homebrew and codeburn is installed with npm install -g codeburn, the menubar's one-click update runs brew upgrade codeburn and fails with Error: codeburn not installed. The popover shows "CLI Update Failed / CodeBurn could not update the CLI."

Why it happens

Homebrew's Node sets the npm global prefix to /opt/homebrew, so the npm launcher lands at /opt/homebrew/bin/codeburn:

$ npm prefix -g
/opt/homebrew
$ readlink /opt/homebrew/bin/codeburn
../lib/node_modules/codeburn/dist/cli.js
$ brew list --formula | grep codeburn
(nothing)

UpdateChecker.cliUpdateInvocation(cliPath:) (mac/Sources/CodeBurnMenubar/Data/UpdateChecker.swift, around line 264) treats any path containing /homebrew/ as a Homebrew install and returns [brew, "upgrade", "codeburn"]. Homebrew has no codeburn formula installed here, so brew exits non-zero. cliUpdateCommand (around line 121) uses the same substring test, so the manual fallback hint also says brew upgrade codeburn.

The existing tests pin this behavior: UpdateCheckerTests.swift expects /opt/homebrew/bin/codeburn to map to brew, and expects nil when only npm exists at that path.

Proposed fix

Decide by where the launcher really points, not by its directory:

  1. Resolve the symlink (URL.resolvingSymlinksInPath() or FileManager.destinationOfSymbolicLink), keeping it injectable like fileExists so the tests stay pure.
  2. Resolved path contains /Cellar/codeburn/ -> brew.
  3. Resolved path contains /node_modules/codeburn/ -> npm from the launcher's directory (/opt/homebrew/bin/npm in this layout).
  4. Otherwise keep the current fallbacks.
  5. Route cliUpdateCommand through the same decision so the manual hint matches.
  6. Tests: a brew-Node + npm-global case (/opt/homebrew/bin/codeburn -> ../lib/node_modules/codeburn/dist/cli.js -> npm) next to the existing Cellar case.

I can send a PR for this if the approach looks right.

Environment

  • macOS 27.0, Apple Silicon
  • CodeBurn menubar 0.9.25, CLI 0.9.25 (npm global)
  • Node from Homebrew (brew list --formula includes node)

Workaround

Run npm install -g codeburn@latest in a terminal; the menubar stops offering the CLI update once the versions match.