fix(sync): force host static-config stages user-writable (read-only source → EACCES)#177
Merged
Merged
Conversation
The static-config stages (`stage{Claude,Codex,Agents,Opencode}StaticForUpload`)
rsync the host's ~/.claude, ~/.codex, ~/.agents, and ~/.local/share/opencode
into a throwaway scratch dir, then rewrite it in place (filter settings.json,
sanitize config.toml, rewrite plugin paths) and finally `rm` it.
Every one of those rsyncs runs `rsync -a`, which implies `-p` and preserves the
*source's* modes. When the source is read-only — skill/plugin symlinks into the
Nix store (0444/0555), or any root-owned / mode-0444 dotfiles — the scratch copy
comes out read-only too. That breaks the stage two ways:
- the in-place `writeFile` rewrites fail with EACCES, and
- cleanup's `rm` can't unlink children of a 0555 dir:
`EACCES: permission denied, unlink '.../skills/1password/SKILL.md'`
which aborts `agentbox prepare` (and the docker/cloud seeds) for anyone whose
agent config is managed declaratively (Nix/home-manager, Ansible, chezmoi, ...).
A scratch dir has no business inheriting the source's perms, so add
`--chmod=Du+rwx,Fu+rw` to each stage rsync. GNU rsync honors it; macOS's
openrsync ignores it and doesn't hit the read-only-source case in practice, so
it's a safe no-op there.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Owner
|
thanks for the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
agentbox prepare(and the docker/cloud seeds) fail for anyone whose agent config is managed declaratively — Nix/home-manager, Ansible, chezmoi, or just root-owned/read-only dotfiles:Root cause
The static-config stages (
stage{Claude,Codex,Agents,Opencode}StaticForUploadinpackages/sandbox-core/src/sync/host-stage.ts) rsync~/.claude,~/.codex,~/.agents, and~/.local/share/opencodeinto a throwaway scratch dir, then rewrite it in place (filtersettings.json, sanitizeconfig.toml, rewrite plugin paths) and finallyrmit.Every one of those rsyncs runs
rsync -a, which implies-pand preserves the source's modes. When the source is read-only — skill/plugin symlinks into the Nix store (0444/0555), or any root-owned /0444dotfile — the scratch copy is read-only too. That breaks the stage two ways:writeFilerewrites fail withEACCES; andrmcan't unlink a child of a0555directory → theunlink .../skills/*/SKILL.mdabove.A normal writable
~/.claudenever hits it, which is why it only bites declaratively-managed hosts.Fix
A scratch dir has no business inheriting the source's perms. Add
--chmod=Du+rwx,Fu+rw(via a shared, documentedSTAGE_WRITABLE_CHMODconstant) to each of the 5 stage rsyncs. GNU rsync honors it; macOS's openrsync ignores it and doesn't hit the read-only-source case in practice, so it's a safe no-op there.Scoped to the static-config stages only — the workspace export rsync is untouched, so its
-iitemized output (parsed byparseItemizedChanges) is unchanged.Reproduce
On a host where
~/.claude/skills/*are read-only symlinks into a read-only store (e.g. home-manager), or synthetically:🤖 Generated with Claude Code