Skip to content

[Bug]: Account switch writes oauthAccount to ~/.claude/.claude.json, so new Claude terminals show the previous account #22667

Closed

Description

@AlgoraAndrew

Operating system

macOS

Orca version

v1.4.203

Details

After switching the managed Claude account, new claude terminals still report the previous account (claude auth status, /status), even though Orca switched the credentials correctly. Orca writes oauthAccount to ~/.claude/.claude.json whenever that file exists. Claude Code only reads that file when CLAUDE_CONFIG_DIR is set. Without it, Claude Code reads ~/.claude.json, which Orca leaves untouched.

Environment

  • Orca 1.4.203, macOS (native host runtime, managed Claude accounts)
  • Claude Code 2.1.281
  • CLAUDE_CONFIG_DIR not set in Orca terminals

Root cause

ClaudeRuntimePathResolver.resolveConfigPath (src/main/claude-accounts/runtime-paths.ts, since #1050):

if (inheritedConfigDir || existsSync(colocatedConfigPath)) {
  return colocatedConfigPath
}
return join(homedir(), '.claude.json')

Claude Code chooses its config file by whether CLAUDE_CONFIG_DIR is set, not by which file exists. Any tool that has ever run Claude with CLAUDE_CONFIG_DIR=~/.claude leaves a ~/.claude/.claude.json behind. One example is the claude-mem plugin's observer, as reported in thedotmack/claude-mem#4149. From then on, every account switch updates the Keychain and .credentials.json, but writes the account metadata to a file the CLI never reads.

Reproduction

  1. Create ~/.claude/.claude.json, for example by running CLAUDE_CONFIG_DIR=~/.claude claude auth status once.
  2. In Orca, switch the managed Claude account from A to B.
  3. In a new Orca terminal, run claude auth status.
    • Expected: account B.
    • Actual: account A. ~/.claude/.claude.json contains B, ~/.claude.json still contains A, and the Keychain holds B's token.

This probe on the same machine confirms which file the CLI reads:

~/.claude.json ~/.claude/.claude.json CLAUDE_CONFIG_DIR claude auth status
B A unset B
B A ~/.claude A

Secondary effect

The system-default snapshot (claude-runtime-auth/system-default-auth.json) captures configOauthAccount through the same resolver. After a fix, a snapshot taken under the old logic can still hold the identity from ~/.claude/.claude.json. Deselecting the managed account would then write that stale identity into ~/.claude.json.

Activity

  1. AmethystLiang commented on Sep 24, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it

  2. nwparker commented on Oct 24, 2026

    @nwparker
    Contributor

    Thanks for the detailed report. This area was rebuilt in #26801 (per-account CLAUDE_CONFIG_DIR and scoped Keychain items, replacing the old credential swap/OAuth refresh code), which removes the code path behind this. Could you check on the latest build? If it still happens, reply or reopen with the details.

  3. nwparker commented on Oct 27, 2026

    @nwparker
    Contributor

    Thanks for the report! This is fixed on main by #26801 (8b2a5e4): accounts now launch with their own CLAUDE_CONFIG_DIR, so Orca no longer writes oauthAccount into the shared ~/.claude/.claude.json on a switch. ClaudeRuntimePathResolver.resolveConfigPath is only used by its own test now. Closing — please reopen if you still see it on the latest build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    os:macosIssues affecting macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions