Skip to content

Commit a285481

Browse files
njbrakeclaude
andauthored
fix: seed .sandbox-gitconfig so git works in Claude Code sandboxes (#336)
Claude Code sets GIT_CONFIG_GLOBAL=/root/.sandbox-gitconfig when IS_SANDBOX=1, but nothing creates the file. Every git command then fails with "fatal: unknown error occurred while reading the configuration files". Seed an empty .sandbox-gitconfig via home_seed_files so it is created on the host and bind-mounted read-write into the container. This also sidesteps a secondary issue where the host's .gitconfig (mounted read-only) can carry a broken credential.helper escape (\!gh instead of !gh) -- with GIT_CONFIG_GLOBAL pointing to the sandbox file, git no longer reads the host .gitconfig. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aa03032 commit a285481

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/session/container_config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ const AGENT_CONFIG_MOUNTS: &[AgentConfigMount] = &[
5757
keychain_credential: Some(("Claude Code-credentials", ".credentials.json")),
5858
// Claude Code reads ~/.claude.json (home level, NOT inside ~/.claude/) for onboarding
5959
// state. Seeding hasCompletedOnboarding skips the first-run wizard.
60-
home_seed_files: &[(".claude.json", r#"{"hasCompletedOnboarding":true}"#)],
60+
// Claude Code sets GIT_CONFIG_GLOBAL=/root/.sandbox-gitconfig when IS_SANDBOX=1;
61+
// the file must exist or all git commands fail.
62+
home_seed_files: &[
63+
(".claude.json", r#"{"hasCompletedOnboarding":true}"#),
64+
(".sandbox-gitconfig", ""),
65+
],
6166
preserve_files: &[".credentials.json", "history.jsonl"],
6267
},
6368
AgentConfigMount {

0 commit comments

Comments
 (0)