fix(mac): prefer the node beside the CLI over a version manager's default - #1266
Merged
Merged
Conversation
…ault
The app built PATH by appending its curated directories after the
inherited value, so whichever `node` came first won -- on an nvm machine
that is the default alias, which can be an older major than the one the
CLI was installed under. Every spawn then died on the engine gate
("codeburn requires Node.js >= 22.13.0 (current: v20.20.2)") and the
popover showed "Could not load Today" with nothing pointing at Node.
augmentedPath now takes the resolved CLI path and, when an executable
node sits in the same directory, moves that directory to the front of
PATH -- promoting it if already present, dropping nothing. That
interpreter is the one that installed the CLI and satisfies its engine
range. A bare `codeburn` or a CLI with no sibling node leaves the
inherited order untouched, so getagentseal#1263's Nix layout is unaffected.
makeProcess resolved the CLI twice, once for PATH and once for argv; it
now resolves once and passes the same value to both.
Three tests cover the reorder, the promote-not-duplicate case, and the
untouched case; removing only the reorder block makes the first two fail
with the reported shape while every pre-existing test still passes.
avs-io
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a machine where a Node version manager's default version is older than the 22.13 the CLI requires, the menubar app renders no data: every CLI spawn exits 1 with
codeburn requires Node.js >= 22.13.0 (current: v20.20.2), and the popover shows "Could not load Today" with nothing pointing at Node.CodeburnCLI.makeProcessruns the CLI through/usr/bin/envand buildsPATHby taking the inherited value and appendingadditionalPathEntriesplususerNodePaths. The published launcher begins#!/usr/bin/env node, so whichevernodecomes first on that PATH wins — and on an nvm machine the first one is the default alias, which is easily an older major than the one the CLI was installed under. The CLI itself lives at~/.nvm/versions/node/v24.20.0/bin/codeburn(resolved and cached byinstalledArgv()), right next to a v24nodethat would run it fine; the app just never puts that directory ahead of the inherited entries.augmentedPathnow takes the resolved CLI path and, when an executablenodesits in the same directory, moves that directory to the front of PATH (promoting it if it was already present, so nothing is duplicated and nothing is dropped). The interpreter beside the CLI is by construction the one that installed it and satisfies its engine range. When the CLI resolves through PATH (barecodeburn) or has no sibling interpreter, the inherited order is left exactly as before — so #1263's Nix layout (CLI in~/.local/bin, node in a profile directory) is untouched, and every existinguserNodePathsconsumer keeps its precedence.makeProcessalso resolved the CLI twice — once for PATH, once for argv. It now resolves once and passes the same value to both, so they cannot disagree about which install a launch is talking about.Change evidence
nodedirectory leads PATHswift test --filter CodeburnCLIPathTests: 7 tests in 1 suite passed. New title: "interpreter beside the CLI wins over an older node on PATH". Fixture: twonodestubs under…/node/v24/binand…/node/v20/bin, inherited PATHv20:/usr/bin:/bin,resolvedCLIpointing intov24/bin. Assertsv24/binis first,v20/binstill present and later./usr/bin:<bin>:/binwithresolvedCLIin<bin>→<bin>first, exactly one occurrence.nodebeside the CLI) must not move.codeburnand an absolute CLI with no siblingnode, PATH begins/usr/bin:/binand the CLI's directory is not inserted.augmentedPath(signature kept so the tests still compile) and re-ran the filter: the two positive tests failed with the reported shape —entries.first → ".../node/v20/bin"wherev24/binwas expected, andentries.first → "/usr/bin"where the CLI's directory was expected — while "PATH order is untouched…" and all four pre-existing tests (mise ×2, Nix ×2) still passed. Restored the block;git diffagainst the staged fix is empty.resolvedCLIinjection parameterbaseArgv(), which reads the persisted CLI path and probes the filesystem; tests pass a fixture path instead. Defaultnilkeeps every existing caller unchanged.makeProcesspassesargv.first.mainswift testfrommac/onmain(4a9d885): 424 tests in 53 suites passed, 0 failed. On this branch: 427 tests in 53 suites passed, 0 failed. Difference is exactly the 3 new tests.>= 22.13.0 (current: v20.20.2)error above. After rebuilding and reinstalling with this change, the status item rendered today's spend within one refresh and the figure matchedcodeburn status --format menubar-json --period todayrun from a shell. Reproduced the spawn directly:PATH="$HOME/.nvm/versions/node/v24.20.0/bin:$PATH" ~/.nvm/versions/node/v24.20.0/bin/codeburn --version→0.9.23…, rc 0; the same command without the prefix on that machine → rc 1 with the engine error.Environment
Observed and fixed on macOS 26 (Darwin 25.6), Apple Silicon.
~/.nvm/alias/default20.20.2codeburn-cli-path.v1)/Users/<user>/.nvm/versions/node/v24.20.0/bin/codeburnnodebeside it/opt/homebrew/bin/nodecodeburn requires Node.js >= 22.13.0 (current: v20.20.2)/Upgrade at https://nodejs.org/Notes
The change is confined to
augmentedPathandmakeProcessinCodeburnCLI.swift. It adds no dependency, alters no public interface, and leavesisSafe,baseArgv,installedArgv,userNodePaths(including #1263's Nix entries) and theCODEBURN_BINoverride untouched. The only PATH entries it can move are ones that were already on PATH or already curated by the app.This is complementary to #1263: that change teaches the app where a Node can be; this one settles which one wins when several are present. The stronger follow-up mentioned there — persisting the interpreter path and spawning
[node, cli.js]directly — would subsume both; this PR keeps the/usr/bin/envdesign.The description above is what this branch does and what was measured; the same defect on Windows (the npm
.cmdshim also resolvesnodevia PATH) is out of scope here.🤖 Generated with Claude Code