fix: keep ~/.claude/hooks scripts executable after skeleton copy - #1
Merged
Conversation
The container entrypoint seeds the home from /etc/skel.agent with cp -rT --no-preserve=mode to keep home files agent-writable, but that strips the +x bit baked into the skeleton hook scripts. Claude Code execs ~/.claude/hooks/*.sh directly (stop-test-runner, test-runner, gitleaks-precommit referenced from managed-settings.json), so they failed with 'Permission denied' on the Stop and PreToolUse events. Re-assert +x on ~/.claude/hooks/*.sh in the entrypoint: once before the fast-path exit so already-initialized homes are repaired, and once after the skeleton copy so the first session on a fresh home works too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Claude Code's Stop hook (and a PreToolUse hook) fail in-container with:
The skeleton hook scripts (
stop-test-runner.sh,test-runner.sh,gitleaks-precommit.sh) are built executable (executable = true+chmod +xinskelDir), but the entrypoint seeds the home with:--no-preserve=mode(kept so home files stay agent-writable) strips the+xbit, so the scripts land at 0644.managed-settings.jsonexecs them directly so Claude Code hits 'Permission denied' on Stop / PreToolUse. The~/.hooks/*.shset is unaffected because it is bind-mounted and chmod'd separately.Fix
Re-assert
+xon~/.claude/hooks/*.shinentrypoint-user:~/.agentbox/homeon darwin hosts) are repaired;Cheap, idempotent globs guarded by
[ -d ... ].🤖 Generated with Claude Code