fix(server): use CLAUDE_CONFIG_DIR instead of HOME for Claude instanc…#4017
fix(server): use CLAUDE_CONFIG_DIR instead of HOME for Claude instanc…#4017dmstoykov wants to merge 4 commits into
Conversation
…e isolation Overriding HOME to isolate a Claude provider instance also relocates the macOS login-keychain lookup ($HOME/Library/Keychains/login.keychain-db), so the spawned CLI cannot read its stored OAuth credentials and returns "Not logged in · Please run /login" on every turn -- even though the auth probe reports "Authenticated". Any Claude provider with a non-empty "Claude HOME path" therefore fails to authenticate on macOS. Set CLAUDE_CONFIG_DIR (Claude Code's per-instance config knob) instead of HOME. It points the CLI at the config dir directly while leaving HOME -- and the keychain -- intact. Verified end-to-end on macOS: an instance with a custom path went from failing every turn to authenticating and completing turns normally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This change modifies runtime behavior by switching from HOME to CLAUDE_CONFIG_DIR for Claude configuration. An unresolved review comment identifies a potential breaking change: existing custom path configurations may become invalid due to the different path semantics between the two environment variables. You can customize Macroscope's approvability policy. Learn more. |
The Claude provider now isolates instances via CLAUDE_CONFIG_DIR instead of HOME. Update the setting's title, description, and placeholder to match -- and to mirror the sibling Codex "CODEX_HOME path" field -- so users don't enter a HOME-style value like `~` and end up pointing at the wrong config dir. The internal schema key stays `homePath` for backward compatibility. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Dismissing prior approval to re-evaluate 1e9b2fa
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2ea4218. Configure here.
The Claude provider now sets CLAUDE_CONFIG_DIR instead of HOME, so the tests that verified the spawned CLI's environment must check CLAUDE_CONFIG_DIR: - ClaudeTextGeneration.test.ts (fake-binary env assertion) - ProviderRegistry.test.ts (status-probe env) - ClaudeAdapter.test.ts (SDK session env) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Head branch was pushed to by a user without write access
Dismissing prior approval to re-evaluate 7fbaf5e
|
@juliusmarminge can you re-approve? |

…e isolation
What Changed
Two commits:
fix(server)—makeClaudeEnvironment(ClaudeHome.ts) now setsCLAUDE_CONFIG_DIRinstead of overridingHOMEfor a configured Claude home path. Test updated.fix(contracts)— relabel the setting (title → "CLAUDE_CONFIG_DIR path", placeholder →~/.claude) so the UI matches the new behavior. Schema key stayshomePath; no migration.Why
Overriding
HOMEalso relocates macOS's login-keychain lookup ($HOME/Library/Keychains/login.keychain-db), so the spawned CLI can't read its OAuth token and returnsNot logged in · Please run /loginon every turn — even though the auth probe shows "Authenticated". Any Claude instance with a custom home path fails to authenticate on macOS.Proof (same shell, only
HOMEdiffers):CLAUDE_CONFIG_DIRis Claude Code's per-instance config knob — it isolates config while leavingHOME(and the keychain) intact. The auth probe spawns the CLI through this same env, so probe and generation stay consistent.Context: the
HOMEoverride was introduced incidentally in #2277 (multi-provider foundation) and never revisited. The sibling Codex provider already uses this exact pattern (CODEX_HOME, realHOMEpreserved), predating the Claude code by ~2 months — so this just aligns Claude with the established precedent. It also finally delivers the work/personal separation requested in #1444 / #2111:HOME-isolation collided on one shared keychain entry, whereasCLAUDE_CONFIG_DIRgives each instance its own.Verified end-to-end on macOS (custom-path instance went from failing every turn to authenticating normally);
ClaudeHomeunit test passes.UI Changes
None (settings label text only).
Checklist
Note
Medium Risk
Changes how every spawned Claude CLI inherits environment for custom home paths (auth, config location); behavior fix with broad provider impact but narrow code surface and strong test coverage.
Overview
Custom Claude
homePathnow isolates config viaCLAUDE_CONFIG_DIRinstead of overridingHOME.makeClaudeEnvironmentsets the resolved path on that variable so spawned Claude Code processes keep the realHOME(and on macOS, the login keychain) while still using a separate config directory.Provider settings copy is updated to describe CLAUDE_CONFIG_DIR semantics (title, description, placeholder
~/.claude); the stored field remainshomePathwith no migration. Tests for SDK sessions, status probes, and text generation now assertCLAUDE_CONFIG_DIRin the child env rather thanHOME.Reviewed by Cursor Bugbot for commit 7fbaf5e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
makeClaudeEnvironmentto setCLAUDE_CONFIG_DIRinstead ofHOMEfor Claude instancesSets
CLAUDE_CONFIG_DIRto the resolved config path whenhomePathis configured, leavingHOMEunchanged to avoid breaking macOS keychain lookups. Updates all related tests and renames thehomePathsetting annotation in the contracts schema from 'Claude HOME path' to 'CLAUDE_CONFIG_DIR path'.Macroscope summarized 7fbaf5e.