Skip to content

fix(update): clean retry web/node_modules on dep-layout mismatch (#34312, #34335)#34373

Open
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/34312-34335-web-update-clean-install
Open

fix(update): clean retry web/node_modules on dep-layout mismatch (#34312, #34335)#34373
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/34312-34335-web-update-clean-install

Conversation

@Bartok9

@Bartok9 Bartok9 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Closes #34312
Closes #34335

Problem

After hermes update, web/node_modules could be left in a half-state that bricks the dashboard:

sh: line 1: tsc: command not found
Could not resolve "./icons/alarm-clock-check.js" from
  "node_modules/lucide-react/dist/esm/lucide-react.js"

Both are classic symptoms of npm doing a non-atomic install over an existing node_modules tree where dep versions changed (lucide-react shifts icon file layouts between versions; missing tsc means TypeScript devDep wasn't materialized to .bin/).

Fix

When _run_npm_install_deterministic fails AND node_modules already exists, wipe it and retry once. Slower updates, but updates that never leave the dashboard in a crash-loop.

Narrow by design:

  • Only triggers when node_modules pre-exists (fresh installs don't pay the wipe cost)
  • Only retries once (avoids hiding npm-binary failures a fresh tree wouldn't solve)
  • Reports the SECOND attempt's error on failure (real diagnostic, not 'install failed on stale tree')
  • Manual recovery line updated to match: cd web && rm -rf node_modules && npm install && npm run build

Tests (4 in test_web_ui_clean_retry.py)

  • Clean retry runs when install fails with node_modules present (the repro path)
  • No clean retry when node_modules absent (fresh install fails fast)
  • Clean retry skipped when first install succeeds (happy path preserved)
  • Both attempts fail → ok=False with real error surface
$ python -m pytest tests/hermes_cli/test_web_ui_clean_retry.py
=== 4 passed in 0.19s ===

🎻 Co-authored-by: Cursor cursoragent@cursor.com

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competes with #34300 and #34306 — all fix SearXNG config-aware env lookup (#34290). This PR has broadest scope (provider.py + web_tools._has_env + diagnostic print). #34300 also covers web_tools; #34306 only provider.py.

@Bartok9 Bartok9 force-pushed the fix/34312-34335-web-update-clean-install branch from bd189b5 to dfc862d Compare June 6, 2026 07:31
@Bartok9

Bartok9 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. This one had a real semantic conflict (not just additive), so worth describing.

Conflict & resolution — hermes_cli/main.py, in _build_web_ui:
main had changed the first npm-install invocation to run from the workspace root and to honor a Termux workspace-install context:

npm_cwd = _workspace_root(web_dir)
npm_workspace_args = ()
if _is_termux_startup_environment():
    npm_cwd, npm_workspace_args = _termux_workspace_install_context(web_dir)
r1 = _run_npm_install_deterministic(npm, npm_cwd, extra_args=(*npm_workspace_args, "--silent"))

This PR (#34312/#34335) had the older signature _run_npm_install_deterministic(npm, web_dir, extra_args=("--silent",)) plus the new clean-retry-on-failure block below it.

A naive 'take theirs' would have regressed main's workspace-root + Termux handling. So I integrated both:

  • Kept main's npm_cwd / Termux computation for the first install.
  • Hoisted the resolved cwd + args into _npm_install_extra_args and made the clean-retry path reuse the same npm_cwd and args rather than the bare web_dir. So the wipe-and-retry now also respects the workspace-root/Termux context — the two fixes compose instead of one clobbering the other.

Verification:

  • pytest tests/hermes_cli/test_web_ui_clean_retry.py — 4 passed (the tests assert call-count + node_modules wipe state, which my integration preserves; they don't pin the cwd to web_dir).
  • Confirmed _workspace_root, _is_termux_startup_environment, _termux_workspace_install_context all exist on current main.
  • ruff check — clean. Syntax check — OK.
  • Now MERGEABLE.

…sResearch#34312, NousResearch#34335)

After 'hermes update', web/node_modules could be left in a half-state
that bricks the dashboard:

  sh: line 1: tsc: command not found
  Could not resolve "./icons/alarm-clock-check.js" from
    "node_modules/lucide-react/dist/esm/lucide-react.js"

Both are classic symptoms of npm doing a non-atomic install over an
existing node_modules tree where dep versions changed across the
update (lucide-react in particular shifts icon file layout between
versions; missing tsc means TypeScript devDep wasn't materialized to
.bin/).

Fix: when _run_npm_install_deterministic fails AND node_modules
already exists, wipe it and retry once. The cost is a slower update;
the win is updates that never leave the dashboard in a crash-loop.

The fix is intentionally narrow:

  * Only triggers when node_modules pre-exists (fresh installs don't
    pay the wipe cost).
  * Only retries once (avoids hiding genuine npm-binary failures that
    a fresh tree wouldn't solve either).
  * Reports the SECOND attempt's error on failure, so the user gets a
    real diagnostic instead of 'install failed on stale tree' that
    doesn't tell them what's actually wrong.
  * Updates the suggested manual recovery line to match what now
    happens automatically: 'cd web && rm -rf node_modules &&
    npm install && npm run build'.

Tests (4 in test_web_ui_clean_retry.py):

  - Clean retry runs when install fails with node_modules present (the
    NousResearch#34312 repro path — first call fails on stale tree, second call
    succeeds after wipe, two install attempts, node_modules wiped
    between).
  - No clean retry when node_modules absent (fresh install \u2192 fail
    fast, one attempt).
  - Clean retry skipped when first install succeeds (happy path \u2192 no
    wipe, one attempt, node_modules preserved).
  - Both attempts fail \u2192 ok=False with the real error surface
    (test_clean_retry_failure_reports_real_error).

Refs: NousResearch#34312 NousResearch#34335
Closes: NousResearch#34312 NousResearch#34335

Co-authored-by: Cursor <cursoragent@cursor.com>
@Bartok9 Bartok9 force-pushed the fix/34312-34335-web-update-clean-install branch from dfc862d to 0d0506f Compare June 8, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

2 participants