From 59f10f92cf8829d758a36072706343ae0eb13207 Mon Sep 17 00:00:00 2001 From: claude-prodromou Date: Mon, 11 May 2026 14:48:23 -0700 Subject: [PATCH] codex-shell: chown global agent CLI to uid 10001 for auto-update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `npm install -g` at L261-264 runs as root (before the USER directive at L318), so /usr/lib/node_modules/@anthropic-ai/ and the matching /usr/bin/claude symlink land owned by root:root. When the agent user (uid 10001) later tries `npm install -g @anthropic-ai/claude-code` to auto-update, npm's reify step renames within /usr/lib/node_modules/ @anthropic-ai/ → EACCES. Fix: after each `npm install -g`, chown the scope directory and the entrypoint symlink to 10001:10001. The agent user is created later in the Dockerfile but the uid/gid 10001 are pinned constants (with an explicit "DO NOT bump uid/gid casually" comment at L266-282), so numeric chown here is safe and order-independent. Same pattern applied to both variants: claude → @anthropic-ai + /usr/bin/claude, codex → @openai + /usr/bin/codex. After this lands and apk8s bumps to the resulting sha, in-pod `npm install -g @anthropic-ai/claude-code` should succeed for the agent user, and claude-code's startup auto-update check should stop showing the "Auto-update failed" banner. Co-Authored-By: Claude Opus 4.7 (1M context) --- Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c1d3701..e6a6f26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -258,9 +258,19 @@ RUN set -eux; \ ARG CLAUDE_CODE_VERSION=2.1.133 # renovate: datasource=npm depName=@openai/codex ARG OPENAI_CODEX_VERSION=0.129.0 +# Install as root (writes to /usr/lib/node_modules), then chown the +# scope directory + entrypoint symlink to uid/gid 10001 so the agent +# user can run `npm install -g` for auto-updates without EACCES on the +# rename within the @scope/ parent. The agent user is created later +# (L282-283) but uid/gid 10001 are pinned constants, so numeric chown +# here is safe and order-independent. RUN case "$AGENT" in \ - codex) npm install -g "@openai/codex@${OPENAI_CODEX_VERSION}" ;; \ - claude) npm install -g "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" ;; \ + codex) npm install -g "@openai/codex@${OPENAI_CODEX_VERSION}" \ + && chown -R 10001:10001 /usr/lib/node_modules/@openai \ + && chown -h 10001:10001 /usr/bin/codex ;; \ + claude) npm install -g "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \ + && chown -R 10001:10001 /usr/lib/node_modules/@anthropic-ai \ + && chown -h 10001:10001 /usr/bin/claude ;; \ esac && npm cache clean --force # Non-root user. uid/gid 10001, name = AGENT.