From ab1d7e6e4b846dc73143fcca9a0237646d9f62f3 Mon Sep 17 00:00:00 2001 From: Dave Eargle Date: Thu, 9 Apr 2026 01:25:04 -0600 Subject: [PATCH] fix search path for .claude.json to account for CLAUDE_CONFIG_DIR (#40) * fix search path for .claude.json to account for CLAUDE_CONFIG_DIR When `CLAUDE_CONFIG_DIR` is set, as is done in `devcontainer.json`, `claude` looks for `.claude.json` in that folder; otherwise, `~` is used. Learned through observation, not claude documentation :old-man-yells-at-cloud: * add more words to the lookup behavior description * Apply suggestion from @DarkaMaul --------- Co-authored-by: dm --- post_install.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/post_install.py b/post_install.py index a6d325c..8c4ec92 100644 --- a/post_install.py +++ b/post_install.py @@ -35,7 +35,11 @@ def setup_onboarding_bypass(): ) return - claude_json = Path.home() / ".claude.json" + # When `CLAUDE_CONFIG_DIR` is set, as is done in `devcontainer.json`, `claude` unexpectedly + # looks for `.claude.json` in *that* folder, instead of in `~`, contradicting the documentation. + # See https://github.com/anthropics/claude-code/issues/3833#issuecomment-3694918874 + claude_json_dir = Path(os.environ.get("CLAUDE_CONFIG_DIR", Path.home())) + claude_json = claude_json_dir / ".claude.json" print("[post_install] Running claude -p to populate auth state...", file=sys.stderr) try: @@ -92,7 +96,7 @@ def setup_onboarding_bypass(): def setup_claude_settings(): """Configure Claude Code with bypassPermissions enabled.""" - claude_dir = Path.home() / ".claude" + claude_dir = Path(os.environ.get("CLAUDE_CONFIG_DIR", Path.home() / ".claude")) claude_dir.mkdir(parents=True, exist_ok=True) settings_file = claude_dir / "settings.json"