Skip to content

fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison#19520

Merged
benbarclay merged 1 commit into
mainfrom
fix_docker_tui
May 4, 2026
Merged

fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison#19520
benbarclay merged 1 commit into
mainfrom
fix_docker_tui

Conversation

@benbarclay

Copy link
Copy Markdown
Collaborator

_tui_need_npm_install() compares the canonical package-lock.json against the hidden node_modules/.package-lock.json to decide whether npm install needs to re-run. npm 9 drops the "peer": true field from the hidden lock on dev-deps that are also declared as peers (the canonical lock preserves the dual annotation). That made the check flag 16 packages (@babel/core, @types/node, @types/react, @typescript-eslint/*, react, vite, tsx, typescript, …) as mismatched on every launch, triggering a runtime npm install.
Inside the Docker image, that runtime install then fails with EACCES because /opt/hermes/ui-tui/node_modules/ is root-owned from build time, so docker run … hermes-agent --tui prints:
Installing TUI dependencies…
npm install failed.
…and exits 1, with no preview. The empty preview is a second bug: the launcher captured only stderr, but npm 9 writes EACCES to stdout, which was DEVNULL'd.
Fixes:

  • Add "peer" to _NPM_LOCK_RUNTIME_KEYS so the comparison ignores the non-deterministic field, alongside the existing "ideallyInert".
  • Capture stdout as well as stderr in the install subprocess so future failures surface a useful preview instead of a bare "failed." line. Regression tests:
  • test_no_install_when_only_peer_annotation_differs — the exact scenario
  • test_install_when_version_differs_even_with_peer_drop — guards against the peer-drop tolerance masking a real version skew On-host impact: the same false-positive was firing on every hermes --tui invocation from a normal checkout, silently running a no-op npm install each time (it converged because the host's node_modules/ is writable). Startup time on the TUI should drop noticeably.

`_tui_need_npm_install()` compares the canonical `package-lock.json` against
the hidden `node_modules/.package-lock.json` to decide whether `npm install`
needs to re-run. npm 9 drops the `"peer": true` field from the hidden lock
on dev-deps that are *also* declared as peers (the canonical lock preserves
the dual annotation). That made the check flag 16 packages (`@babel/core`,
`@types/node`, `@types/react`, `@typescript-eslint/*`, `react`, `vite`,
`tsx`, `typescript`, …) as mismatched on every launch, triggering a runtime
`npm install`.
Inside the Docker image, that runtime install then fails with EACCES because
`/opt/hermes/ui-tui/node_modules/` is root-owned from build time, so
`docker run … hermes-agent --tui` prints:
    Installing TUI dependencies…
    npm install failed.
…and exits 1, with no preview. The empty preview is a second bug: the
launcher captured only stderr, but npm 9 writes EACCES to stdout, which
was DEVNULL'd.
Fixes:
 - Add `"peer"` to `_NPM_LOCK_RUNTIME_KEYS` so the comparison ignores the
   non-deterministic field, alongside the existing `"ideallyInert"`.
 - Capture stdout as well as stderr in the install subprocess so future
   failures surface a useful preview instead of a bare "failed." line.
Regression tests:
 - `test_no_install_when_only_peer_annotation_differs` — the exact scenario
 - `test_install_when_version_differs_even_with_peer_drop` — guards against
   the peer-drop tolerance masking a real version skew
On-host impact: the same false-positive was firing on every `hermes --tui`
invocation from a normal checkout, silently running a no-op `npm install`
each time (it converged because the host's `node_modules/` is writable).
Startup time on the TUI should drop noticeably.
@benbarclay benbarclay requested a review from OutThisLife May 4, 2026 04:14
@alt-glitch alt-glitch added area/docker Docker image, Compose, packaging comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working labels May 4, 2026
@benbarclay benbarclay merged commit 95f3950 into main May 4, 2026
10 of 11 checks passed
@benbarclay benbarclay deleted the fix_docker_tui branch May 4, 2026 04:29
jsboige pushed a commit to jsboige/hermes-agent that referenced this pull request May 14, 2026
fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
fix(docker/tui): tolerate npm's peer-flag drop in lockfile comparison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants