Skip to content

Commit 2657a25

Browse files
lroolleclaude
andcommitted
fix: revert XDG config mounting and add GitHub CLI auth support
- Revert broad ~/.config mounting that caused issues - Restore specific ~/.config/gcloud mounting for Vertex AI - Add GH_TOKEN and GITHUB_TOKEN environment variable passthrough - Document GitHub CLI authentication in README - Research keyring vs container auth challenges in dev logs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 30a906d commit 2657a25

4 files changed

Lines changed: 69 additions & 10 deletions

File tree

DEV-LOGS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,44 @@
55

66
## Issue Analysis: 2025-06-22
77

8+
### [problem-discovered] GitHub CLI auth fails in containers
9+
10+
**Problem**: Mounting `~/.config/gh/` doesn't work for GitHub CLI authentication in containers.
11+
12+
**Root Cause**: Modern `gh` uses secure keyring storage instead of plain text files:
13+
- **Host**: Tokens stored in macOS Keychain/Linux Secret Service/Windows Credential Manager
14+
- **Container**: No keyring access, auth fails even with mounted config directory
15+
- **Split State**: Config files present but tokens inaccessible
16+
17+
**Technical Details**:
18+
```bash
19+
# Host auth state:
20+
~/.config/gh/config.yml # Configuration
21+
~/.config/gh/hosts.yml # May contain tokens OR keyring references
22+
System Keyring # Actual tokens (secure storage)
23+
24+
# Container reality:
25+
/root/.config/gh/config.yml # ✅ Mounted successfully
26+
/root/.config/gh/hosts.yml # ✅ Mounted but may reference unavailable keyring
27+
No System Keyring # ❌ DBus/keyring services not available
28+
```
29+
30+
**Why This Matters**: Current codebase has complete auth system for Claude/AWS/GCloud but GitHub CLI missing.
31+
32+
**Immediate Impact**: Cannot create PRs or manage GitHub repos from within containers.
33+
34+
**Solutions Research**:
35+
1. **Environment Variable**: `GH_TOKEN="ghp_xxx"` - simple, headless-friendly
36+
2. **Insecure Storage**: `gh auth login --insecure-storage` on host, then mount works
37+
3. **Token Injection**: `echo $TOKEN | gh auth login --with-token` in container
38+
4. **Mount Strategy**: Add explicit GitHub CLI auth mounting to claude.sh
39+
40+
**Status**: Research complete, need implementation decision.
41+
42+
---
43+
44+
## Issue Analysis: 2025-06-22
45+
846
### [enhancement] Controlled auth directory mounting
947

1048
**Problem**: Symlinking all /root/* was too broad and risky.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ claude.sh --help # Show all options
6262
- **AWS Bedrock**: Uses `~/.aws` credentials - `--auth-with bedrock`
6363
- **Google Vertex**: Uses `~/.config/gcloud` credentials - `--auth-with vertex`
6464

65+
## GitHub CLI Authentication
66+
67+
For GitHub operations (creating PRs, managing repos), set the `GH_TOKEN` environment variable:
68+
69+
```bash
70+
# Set your GitHub token
71+
export GH_TOKEN="ghp_xxxxxxxxxxxx"
72+
73+
# Now gh commands work in containers
74+
claude-yolo .
75+
# Inside container: gh pr create, gh issue list, etc.
76+
```
77+
78+
**Note**: This avoids mounting `~/.config/gh/` which fails due to secure keyring storage in modern GitHub CLI versions.
79+
6580
## Custom Volume Mounting
6681

6782
You can mount additional configuration files or directories using the `-v` flag:

claude.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ show_help() {
6060
echo " DISABLE_TELEMETRY Disable Claude Code telemetry"
6161
echo " CLAUDE_YOLO_DOCKER_SOCKET Mount Docker socket (default: false, set to 'true' to enable)"
6262
echo " CLAUDE_EXTRA_VOLUMES Extra volumes to mount in the container"
63+
echo " GH_TOKEN GitHub CLI authentication token"
64+
echo " GITHUB_TOKEN GitHub CLI authentication token (alternative)"
6365
echo ""
6466
echo "Available models: sonnet-4, opus-4, sonnet-3-7, sonnet-3-5, haiku-3-5, sonnet-3, opus-3, haiku-3, deepseek-r1"
6567
echo ""
@@ -72,6 +74,7 @@ show_help() {
7274
echo " $0 --yolo --auth-with bedrock . # YOLO mode with Bedrock"
7375
echo " $0 --yolo -v ~/.ssh:/root/.ssh:ro . # YOLO mode with volume mount"
7476
echo " ANTHROPIC_MODEL=opus-4 $0 . # Use Opus 4 with default auth"
77+
echo " GH_TOKEN=ghp_xxx $0 --yolo . # YOLO mode with GitHub CLI auth"
7578
echo ""
7679
}
7780

@@ -421,10 +424,6 @@ if [ -d "${CURRENT_DIR}/.claude" ]; then
421424
DOCKER_ARGS+=("-v" "${CURRENT_DIR}/.claude:${CURRENT_DIR}/.claude")
422425
fi
423426

424-
# Mount .config directory for XDG-compliant tools (gh, gcloud, git, etc.)
425-
if [ -d "$HOME/.config" ]; then
426-
DOCKER_ARGS+=("-v" "$HOME/.config:/root/.config:ro")
427-
fi
428427

429428
# Mount for AWS bedrock api
430429
if [ -d "$HOME/.aws" ]; then
@@ -497,6 +496,10 @@ fi
497496
[ -n "$GIT_COMMITTER_NAME" ] && DOCKER_ARGS+=("-e" "GIT_COMMITTER_NAME=$GIT_COMMITTER_NAME")
498497
[ -n "$GIT_COMMITTER_EMAIL" ] && DOCKER_ARGS+=("-e" "GIT_COMMITTER_EMAIL=$GIT_COMMITTER_EMAIL")
499498

499+
# Pass GitHub CLI authentication
500+
[ -n "$GH_TOKEN" ] && DOCKER_ARGS+=("-e" "GH_TOKEN=$GH_TOKEN")
501+
[ -n "$GITHUB_TOKEN" ] && DOCKER_ARGS+=("-e" "GITHUB_TOKEN=$GITHUB_TOKEN")
502+
500503
# Pass Node.js development variables
501504
[ -n "$NODE_ENV" ] && DOCKER_ARGS+=("-e" "NODE_ENV=$NODE_ENV")
502505
[ -n "$DEBUG" ] && DOCKER_ARGS+=("-e" "DEBUG=$DEBUG")
@@ -608,7 +611,9 @@ case "$AUTH_MODE" in
608611
if [ -n "$GOOGLE_APPLICATION_CREDENTIALS" ] && [ -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then
609612
DOCKER_ARGS+=("-v" "$GOOGLE_APPLICATION_CREDENTIALS:$GOOGLE_APPLICATION_CREDENTIALS")
610613
fi
611-
# .config/gcloud is already mounted via the general .config mount above
614+
if [ -d "$HOME/.config/gcloud" ]; then
615+
DOCKER_ARGS+=("-v" "$HOME/.config/gcloud:/root/.config/gcloud")
616+
fi
612617

613618
echo "Main model: $ANTHROPIC_MODEL"
614619
echo "Fast model: $ANTHROPIC_SMALL_FAST_MODEL"

docker-entrypoint.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ setup_nonroot_user() {
102102
ln -sfn /root/.claude.json "$CLAUDE_HOME/.claude.json"
103103
fi
104104

105-
# Essential: Handle .config directory (XDG - includes git, gh, gcloud, etc.)
106-
if [ -d "/root/.config" ]; then
107-
echo "[entrypoint] linking .config directory"
108-
chmod -R 755 /root/.config 2>/dev/null || true
109-
ln -sfn /root/.config "$CLAUDE_HOME/.config"
105+
# Essential: Handle .config/gcloud directory for Google Vertex AI
106+
if [ -d "/root/.config/gcloud" ]; then
107+
echo "[entrypoint] linking .config/gcloud"
108+
mkdir -p "$CLAUDE_HOME/.config"
109+
chmod -R 755 /root/.config/gcloud 2>/dev/null || true
110+
ln -sfn /root/.config/gcloud "$CLAUDE_HOME/.config/gcloud"
110111
fi
111112

112113
# Common: AWS credentials

0 commit comments

Comments
 (0)