[BUG] Claude Code writes .claude.json to wrong location in containerized environments
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code writes .claude.json to the home directory (~/.claude.json) instead of the config directory (~/.claude/.claude.json) when running in containerized environment with bind-mounted subdirectories.
This causes:
- The personalized welcome screen ("Welcome back [Name]!") never appears
- The oauthAccount data (including displayName) is not accessible to Claude Code
Workaround: Set environment variable (export CLAUDE_CONFIG_DIR=~/.claude) and restart claude.
What Should Happen?
When CLAUDE_CONFIG_DIR is not set Claude Code should default to ~/.claude
Error Messages/Logs
Debug log showing wrong path (~/.claude/debug/latest):
2025-12-17T09:31:25.259Z [DEBUG] Renaming /home/vscode/.claude.json.tmp.XXXXX.XXXXXXXXXXXXX to /home/vscode/.claude.json
2025-12-17T09:31:25.259Z [DEBUG] File /home/vscode/.claude.json written atomically
File location verification:
# File exists in WRONG location
$ ls -la ~/.claude.json
/home/vscode/.claude.json
# File MISSING from correct location
$ ls -la ~/.claude/.claude.json
ls: cannot access '/home/vscode/.claude/.claude.json': No such file or directory
Steps to Reproduce
- Create a container with the ~/.claude/ directory pre-created (e.g., by Dockerfile or init script)
- Bind-mount subdirectories into ~/.claude/:
# docker-compose.yaml
volumes:
- ./commands:/home/vscode/.claude/commands
- ./skills:/home/vscode/.claude/skills
- ./settings.json:/home/vscode/.claude/settings.json
- Install Claude Code natively inside the container:
curl -fsSL https://claude.ai/install.sh | bash
- Run claude login and complete OAuth flow
- Verify file locations:
# credentials.json is in correct location
ls ~/.claude/.credentials.json # EXISTS ✓
# .claude.json is in WRONG location
ls ~/.claude/.claude.json # MISSING ✗
ls ~/.claude.json # EXISTS (wrong!)
- Run claude - observe no welcome screen appears
- Workaround: Set environment variable and restart:
export CLAUDE_CONFIG_DIR=~/.claude
claude # Welcome screen now appears
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.0.71
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗