fix(desktop): prevent Windows installs from using stale system Node - #82355
fangliquanflq wants to merge 1 commit into
Conversation
Native Win11 verification (monerostar)Could not leave a formal Approve (external collaborator scope) — review-as-comment with live evidence. Host: Microsoft Windows 11 Pro · OS Version 10.0.26200 Build 26200 · x64 Why this fix is right
This PR normalizes with Live contrast (same inputs)Live PR call also returned managed-first with duplicates collapsed; Tests (native Win11, this checkout)Notes
LGTM from native Windows 11 for landing. |
|
Historical current-main validation receipt, superseded by the later topology decision below:
This comment no longer requests replacement or closure of #82355. |
|
Current-main validation receipt: #91188 rebased this exact three-file managed-Node PATH surface onto current GitHub currently reports this original PR mergeable. I am keeping #82355 as the canonical contribution/provenance owner and closing #91188 as a validation duplicate rather than replacing the original contributor's PR. |
What does this PR do?
On Windows, Desktop dependency installation can run npm with Hermes-managed Node while npm lifecycle children resolve an older system Node from PATH. Electron postinstall then fails with
ERR_REQUIRE_ESM, blocking Desktop builds and updates even though Hermes has already installed a compatible Node runtime.This change makes the dependency-install environment move all Hermes-managed Node directories to the front of PATH. It removes normalized duplicate entries first, including Windows case and trailing-separator variants, while preserving the order of unrelated PATH entries.
Related Issue
Closes #82309
Type of Change
Changes Made
hermes_constants.py- normalize PATH entries with platform path semantics, remove managed-directory duplicates, and prepend canonical managed Node directories.tests/test_hermes_constants.py- cover managed Node reordering and Windows duplicate normalization.tests/hermes_cli/test_gui_command.py- cover Desktop install environments when managed Node is missing from PATH or appears after system Node.How to Test
noderesolves to the managed runtime.scripts/run_tests.sh tests/test_hermes_constants.py -k 'managed_node_dirs_move_ahead or windows_managed_node_path_collapses' scripts/run_tests.sh tests/hermes_cli/test_gui_command.pyObserved results: 2 focused PATH tests passed and all 13 Desktop GUI command tests passed. In the Windows real environment, bare
noderesolved to managed Node v22.23.1 after the change instead of the older system Node.Checklist
Code
fix(scope):,feat(scope):, etc.)Documentation & Housekeeping
Screenshots / Logs