fix(scripts): gate Node version in desktop rebuild path - #85997
Conversation
afc058a to
d46b779
Compare
fix(scripts): gate Node version in desktop rebuild path — good extraction of a shared predicate and a pragmatic no-download rebuild gate. Observations:
|
d46b779 to
7747582
Compare
|
Agreed — the "single source of truth" claim was not accurate while install.sh carried its own copy. We went further than syncing the comment: the desktop gate no longer hardcodes any version set at all. Note the two gates are intentionally distinct: install.sh's |
|
Windows complement published in #91079. This PR remains the POSIX desktop-update Node gate. #91079 closes the different direct Windows The Windows wrapper now selects npm's exact Exact Windows head: |
|
Thanks for the complement — this splits cleanly. #91079 owns the Windows direct packaging path (npm's exact Good to see the same Node floor on both sides: our predicate in #85997 is the engines-derived |
The desktop dependency tree (nanoid@6 and friends) only accepts Node 22.22+/24/26+; odd-numbered releases (23/25) pass the root engines.node floor but then die in npm ci with EBADENGINE. hermes update makes the GUI build failure non-fatal, so a bad Node silently leaves the user on the previous build with a generic rebuild-failed message. Gate the REBUILD path (scripts/desktop-update/posix.sh): prefer an already-installed compatible Node on PATH; otherwise look for a Homebrew/usr-local Node to prepend. The version predicate is not hardcoded — node-version-check.js reads apps/desktop/package.json's engines.node fresh on every run (now ^22.22.0 || ^24.0.0 || >=26.0.0, matching nanoid@6), so the gate follows the official declaration with no manual copy to keep in sync. Adds --self-test-node-gate for tests.
7747582 to
c74e205
Compare
fix(scripts): gate Node version in desktop rebuild path
Problem
hermes updateon a machine whose defaultnodeis incompatible with thedesktop build (e.g. Node 25 +
nanoid@6, which requires^22 || ^24 || >=26)silently fails during the Electron rebuild step:
install.shalready gates the Node version for installation (see fix(dashboard): stop Node 25 installs from failing at nanoid #84397),but the desktop rebuild path (
scripts/desktop-update/posix.sh) has noequivalent guard —
hermes updatereports a generic failure and leaves theuser running the previous build, with no hint that the Node version is the
cause.
hermes desktop --force-build --build-onlydirectly, as documented in the [Bug]:
hermes dashboardfails on Node 25 after update due to engine-strict and nanoid@6 #84359 comment.Change
scripts/desktop-update/posix.sh:node_satisfies_build()evaluates a candidateNode against the desktop's declared floor. The predicate is NOT hardcoded:
it reads
apps/desktop/package.json'sengines.nodefresh on every callvia the dependency-free
scripts/lib/node-version-check.jssemverevaluator, so when the official dependency declaration changes the gate
follows automatically — no manual copy to keep in sync.
apps/desktop/package.jsonnow carriesthe real floor
^22.22.0 || ^24.0.0 || >=26.0.0(matchingnanoid@6),replacing the looser
>=22.22.0that let odd-numbered releases 23/25 passthe root floor and then die in
npm ciwith EBADENGINE.prepare_node_for_build()runsbefore the update/rebuild: if PATH already has a compatible node, leave it
alone; otherwise probe the standard Homebrew versioned installs
(
/opt/homebrew/opt/node@22|24|26/bin,/usr/local/opt/...) and prependthe first compatible one to PATH.
HERMES_NODE_CANDIDATE_DIRSoverridesthe candidate list for custom layouts. A candidate only counts if both
nodeandnpmare present.--self-test-node-gate --node-version <v>printscompatible/incompatiblefor CI tests, mirroring the official--self-test-gateprecedent.exit-6 message now includes the Node version actually used.
Tests (
tests-js/desktop-rebuild-node-gate.test.ts, 8 tests) drive theself-test gate over the version matrix, assert the shared evaluator matches
the gate, and cover candidate selection (node-without-npm is skipped, node+npm
candidate is picked). Full
tests-jssuite: 32/32 passing.Design note — install vs rebuild
The install path (#84397, since tightened further to require Node 26 with the
Hermes-managed toolchain) can afford to be strict on a fresh install; the
REBUILD path must be tolerant of existing machines, so this PR auto-selects an
already-installed compatible Node instead of failing. They are complementary:
the gate stays strict about what Node is used, while users with a valid Node
installed somewhere on the machine (very common on macOS via Homebrew versioned
formulae) aren't forced to edit their PATH just to run an update.
Related
hermes dashboardfails on Node 25 after update due to engine-strict and nanoid@6 #84359 — same root cause reported for the desktop rebuild /--force-buildpath