Skip to content

fix(docker): chown gateway install tree on UID remap (salvage #37928)#38655

Merged
benbarclay merged 1 commit into
mainfrom
fix/docker-chown-gateway-tree-salvage-37928
Jun 4, 2026
Merged

fix(docker): chown gateway install tree on UID remap (salvage #37928)#38655
benbarclay merged 1 commit into
mainfrom
fix/docker-chown-gateway-tree-salvage-37928

Conversation

@benbarclay

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #37928 (@sarvesh1327), reduced to the still-needed delta.

/opt/hermes/gateway is a runtime-writable Python package: on first import the supervised gateway writes __pycache__ beneath it, and the image does not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot (e.g. Unraid 99), usermod -u only re-chowns the hermes home dir; the build trees under /opt/hermes keep the build-time UID (10000). main already chowns .venv, ui-tui, and node_modules on remap (#38556) but missed gateway, so the remapped gateway hits EACCES writing __pycache__ (#27221).

This adds /opt/hermes/gateway to both chown sites:

  • the Dockerfile build-time chown -R hermes:hermes line
  • the stage2-hook build-tree ownership repair

so it tracks the remapped UID like its sibling trees.

Differences from #37928 as submitted

Dropped the uid_gid_remapped flag and the || [ "$uid_gid_remapped" = true ] chown gate. main's #38556 already solved that half, and more correctly — it probes the actual tree ownership (venv_owner != actual_hermes_uid) rather than tracking same-boot remaps, which also catches pre-existing ownership drift and stays idempotent. Keeping #37928's flag would regress that. The salvage is the gateway-tree addition only.

Credit preserved via Co-authored-by:.

Verification

Unit: test_dockerfile_node_modules_perms.py + new test_stage2_hook_install_dir_chown.py — 3 tests, green. shellcheck docker/stage2-hook.sh clean.

End-to-end against a real image build:

Fixes #27221.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/docker-chown-gateway-tree-salvage-37928 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9782 on HEAD, 9781 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/tools/test_stage2_hook_install_dir_chown.py:16: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 5073 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of PR #38655

Title: fix(docker): chown gateway install tree on UID remap (salvage #37928)

Issues

  • Outstanding TODO/FIXME/HACK markers remain.

Reviewed by Hermes Agent

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists area/docker Docker image, Compose, packaging backend/docker Docker container execution comp/gateway Gateway runner, session dispatch, delivery labels Jun 4, 2026
Salvage of #37928 (@sarvesh1327), reduced to the still-needed delta.

`/opt/hermes/gateway` is a runtime-writable Python package: on first import
the supervised gateway writes `__pycache__` beneath it, and the image does
not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot
(e.g. Unraid 99), `usermod -u` only re-chowns the hermes home dir; the build
trees under /opt/hermes keep the build-time UID (10000). main already chowns
`.venv`, `ui-tui`, and `node_modules` on remap (#38556) but missed `gateway`,
so the remapped gateway hits EACCES writing `__pycache__` (#27221).

Add `/opt/hermes/gateway` to both chown sites — the Dockerfile build-time
`chown -R hermes:hermes` line and the stage2-hook build-tree repair — so it
tracks the remapped UID like the sibling trees.

Differs from #37928 as submitted: dropped the `uid_gid_remapped` flag and the
`|| [ "$uid_gid_remapped" = true ]` chown gate. main's #38556 already solved
that half, and more correctly — it probes the actual tree ownership
(`venv_owner != actual_hermes_uid`) rather than tracking same-boot remaps,
which also catches pre-existing ownership drift and stays idempotent. Keeping
#37928's flag would regress that. The salvage is the `gateway`-tree addition
only.

Verified end-to-end against a real image build: on baseline main a remap to
UID 99 leaves `gateway` owned by 10000 and a write as uid 99 fails EACCES;
with this change `gateway` is chowned to 99:100 and the write succeeds, while
the default-uid (no-remap) path is unchanged.

Fixes #27221.

Co-authored-by: Sarvesh <sarveshagl1327@gmail.com>
@benbarclay benbarclay force-pushed the fix/docker-chown-gateway-tree-salvage-37928 branch from 59fd4a6 to 0e060aa Compare June 4, 2026 03:20
@benbarclay benbarclay merged commit 03ba06e into main Jun 4, 2026
25 checks passed
@benbarclay benbarclay deleted the fix/docker-chown-gateway-tree-salvage-37928 branch June 4, 2026 03:34
Yuki-14544869 pushed a commit to Yuki-14544869/hermes-agent that referenced this pull request Jun 4, 2026
…earch#37928) (NousResearch#38655)

Salvage of NousResearch#37928 (@sarvesh1327), reduced to the still-needed delta.

`/opt/hermes/gateway` is a runtime-writable Python package: on first import
the supervised gateway writes `__pycache__` beneath it, and the image does
not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot
(e.g. Unraid 99), `usermod -u` only re-chowns the hermes home dir; the build
trees under /opt/hermes keep the build-time UID (10000). main already chowns
`.venv`, `ui-tui`, and `node_modules` on remap (NousResearch#38556) but missed `gateway`,
so the remapped gateway hits EACCES writing `__pycache__` (NousResearch#27221).

Add `/opt/hermes/gateway` to both chown sites — the Dockerfile build-time
`chown -R hermes:hermes` line and the stage2-hook build-tree repair — so it
tracks the remapped UID like the sibling trees.

Differs from NousResearch#37928 as submitted: dropped the `uid_gid_remapped` flag and the
`|| [ "$uid_gid_remapped" = true ]` chown gate. main's NousResearch#38556 already solved
that half, and more correctly — it probes the actual tree ownership
(`venv_owner != actual_hermes_uid`) rather than tracking same-boot remaps,
which also catches pre-existing ownership drift and stays idempotent. Keeping
NousResearch#37928's flag would regress that. The salvage is the `gateway`-tree addition
only.

Verified end-to-end against a real image build: on baseline main a remap to
UID 99 leaves `gateway` owned by 10000 and a write as uid 99 fails EACCES;
with this change `gateway` is chowned to 99:100 and the write succeeds, while
the default-uid (no-remap) path is unchanged.

Fixes NousResearch#27221.

Co-authored-by: Sarvesh <sarveshagl1327@gmail.com>
j2h4u added a commit to j2h4u/hermes-agent that referenced this pull request Jun 4, 2026
Brings deploy up to upstream/main (468 commits, 2026-05-31 → 06-04).

All three carried docker patches are now superseded by upstream and dropped
— merge result is byte-identical to upstream/main:

- 5031c9e (chown install trees independently of volume ownership)
  → superseded by upstream's "Fix ownership of build trees under $INSTALL_DIR"
    block in stage2-hook.sh (NousResearch#38655/NousResearch#38556), a strict superset that also
    covers the gateway tree and documents the NousResearch#35027 gating regression.

- e1fc281 (avoid implicit chown of host hermes home)
- 810534f (silence install stamp on protected mounts)
  → superseded by the s6-overlay boot migration (feat(docker)! e0e9c89),
    which turned entrypoint.sh into a deprecated shim and moved all chown /
    setup logic into cont-init.d/01-hermes-setup (stage2-hook.sh). Upstream's
    targeted HERMES_HOME chown now chowns the dir itself, not bind-mount
    contents — exactly the behavior our patch protected.

deploy now carries no local diff vs upstream/main.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
davidgut1982 pushed a commit to davidgut1982/hermes-agent that referenced this pull request Jun 5, 2026
…earch#37928) (NousResearch#38655)

Salvage of NousResearch#37928 (@sarvesh1327), reduced to the still-needed delta.

`/opt/hermes/gateway` is a runtime-writable Python package: on first import
the supervised gateway writes `__pycache__` beneath it, and the image does
not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot
(e.g. Unraid 99), `usermod -u` only re-chowns the hermes home dir; the build
trees under /opt/hermes keep the build-time UID (10000). main already chowns
`.venv`, `ui-tui`, and `node_modules` on remap (NousResearch#38556) but missed `gateway`,
so the remapped gateway hits EACCES writing `__pycache__` (NousResearch#27221).

Add `/opt/hermes/gateway` to both chown sites — the Dockerfile build-time
`chown -R hermes:hermes` line and the stage2-hook build-tree repair — so it
tracks the remapped UID like the sibling trees.

Differs from NousResearch#37928 as submitted: dropped the `uid_gid_remapped` flag and the
`|| [ "$uid_gid_remapped" = true ]` chown gate. main's NousResearch#38556 already solved
that half, and more correctly — it probes the actual tree ownership
(`venv_owner != actual_hermes_uid`) rather than tracking same-boot remaps,
which also catches pre-existing ownership drift and stays idempotent. Keeping
NousResearch#37928's flag would regress that. The salvage is the `gateway`-tree addition
only.

Verified end-to-end against a real image build: on baseline main a remap to
UID 99 leaves `gateway` owned by 10000 and a write as uid 99 fails EACCES;
with this change `gateway` is chowned to 99:100 and the write succeeds, while
the default-uid (no-remap) path is unchanged.

Fixes NousResearch#27221.

Co-authored-by: Sarvesh <sarveshagl1327@gmail.com>
changman pushed a commit to changman/hermes-agent that referenced this pull request Jun 10, 2026
…earch#37928) (NousResearch#38655)

Salvage of NousResearch#37928 (@sarvesh1327), reduced to the still-needed delta.

`/opt/hermes/gateway` is a runtime-writable Python package: on first import
the supervised gateway writes `__pycache__` beneath it, and the image does
not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot
(e.g. Unraid 99), `usermod -u` only re-chowns the hermes home dir; the build
trees under /opt/hermes keep the build-time UID (10000). main already chowns
`.venv`, `ui-tui`, and `node_modules` on remap (NousResearch#38556) but missed `gateway`,
so the remapped gateway hits EACCES writing `__pycache__` (NousResearch#27221).

Add `/opt/hermes/gateway` to both chown sites — the Dockerfile build-time
`chown -R hermes:hermes` line and the stage2-hook build-tree repair — so it
tracks the remapped UID like the sibling trees.

Differs from NousResearch#37928 as submitted: dropped the `uid_gid_remapped` flag and the
`|| [ "$uid_gid_remapped" = true ]` chown gate. main's NousResearch#38556 already solved
that half, and more correctly — it probes the actual tree ownership
(`venv_owner != actual_hermes_uid`) rather than tracking same-boot remaps,
which also catches pre-existing ownership drift and stays idempotent. Keeping
NousResearch#37928's flag would regress that. The salvage is the `gateway`-tree addition
only.

Verified end-to-end against a real image build: on baseline main a remap to
UID 99 leaves `gateway` owned by 10000 and a write as uid 99 fails EACCES;
with this change `gateway` is chowned to 99:100 and the write succeeds, while
the default-uid (no-remap) path is unchanged.

Fixes NousResearch#27221.

Co-authored-by: Sarvesh <sarveshagl1327@gmail.com>
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 backend/docker Docker container execution comp/gateway Gateway runner, session dispatch, delivery 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.

[Bug]: entrypoint.sh misses chown for ui-tui/ and gateway/ when HERMES_UID is remapped

3 participants