Skip to content

fix(workspace): chown /workspace when root-owned bind mount (#13) - #47

Merged
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/issue-13-workspace-chown
Apr 14, 2026
Merged

fix(workspace): chown /workspace when root-owned bind mount (#13)#47
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/issue-13-workspace-chown

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Resolves #13 (Part A — chown). Part B (private-repo initial_prompt clone) was already addressed by PR #20.

Problem

On Docker Desktop (macOS / Windows), host-path bind mounts commonly appear root-owned inside the container because the host uid doesn't map cleanly. Agents run as uid=1000, so git clone, pip install, and file edits under /workspace/repo/* fail with EACCES — Hermes Dev Lead saw this today and had to fall back to /tmp/hermes-work + emit a patch file.

The previous entrypoint chowned only the /workspace top-level, which wasn't enough: contents stayed root-owned.

Approach

In workspace-template/entrypoint.sh, after the existing top-level chown, sample the first entry inside /workspace. If it's root-owned, assume the whole tree came in via a root-owned bind mount and do a full chown -R agent:agent /workspace. Otherwise skip — on normal Linux Docker with matching uids this stays a no-op, preserving the existing fast-startup path.

The block runs in the existing root branch of the entrypoint, before the exec gosu agent handoff to the agent user, so no Dockerfile changes are needed.

Test plan

  • bash -n workspace-template/entrypoint.sh passes
  • shellcheck clean on new lines (pre-existing SC2164 on line 81 is unrelated)
  • Manual: docker build + docker run -v <root-owned-dir>:/workspace → agent can write to /workspace/repo/*
  • CI: platform/canvas/python test suites remain green

🤖 Generated with Claude Code

…ned (#13)

On Docker Desktop (macOS/Windows), host-path bind mounts often appear
root-owned inside the container. The previous entrypoint only chowned
/workspace top-level, so agents (uid 1000) still couldn't write to
/workspace/repo/* — git clone, pip install, and file edits failed with
EACCES and fell back to /tmp. Detect the root-owned-contents case by
sampling the first entry; if it's root-owned, recursively chown the
tree. On normal Linux Docker with matching uids this is a no-op, so the
fast-startup path is preserved for the common case.

Part B of the issue (private-repo initial_prompt clone) was addressed
by PR #20.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit marked this pull request as ready for review April 14, 2026 14:30
@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor Author

Gates 1-7 pass:

  • Gate 1: CI 6/6 green + 1 skipped (Canvas Deploy Reminder)
  • Gate 2: Only entrypoint.sh changed; bash -n clean; shellcheck clean (pre-existing SC2164 on L81 unrelated)
  • Gate 3: Local Docker build skipped to stay efficient; shell syntax + CI cover it
  • Gate 4: Chown block properly guarded (root uid + -d /workspace + sample stat %u==0), idempotent, runs BEFORE exec gosu agent, no new env vars/secrets
  • Gate 5: Keeps tini/gosu pattern; fast-startup preserved on Linux Docker (guard is false there)
  • Gate 6: Sample-based detection via find -mindepth 1 -maxdepth 1 -print -quit handles empty /workspace gracefully (-n check); recursive chown cost acceptable since only triggers on Docker Desktop/Windows bind-mount scenario that would otherwise EACCES
  • Gate 7: N/A (no canvas)
  • E2E: tests/e2e/test_api.sh 62/62 pass

Merging.

@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit af54fe8 into main Apr 14, 2026
7 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/issue-13-workspace-chown branch April 14, 2026 15:11
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
fix(workspace): chown /workspace when root-owned bind mount (#13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace bind-mount: root-owned /workspace + initial_prompt clone fails for private repos

1 participant