claude-code - 💡(How to fix) Fix [BUG] env in ~/.claude/settings.json breaks OAuth authentication on macOS [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49659Fetched 2026-04-17 08:34:55
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×4closed ×1

Error Message

env entries in settings.json that are unrelated to authentication should not affect credential loading. At minimum, if this is an intended interaction, there should be a clear error message pointing to settings.env as the cause rather than a generic Not logged in.

Error Messages/Logs

Root Cause

This is especially confusing because the variables involved (CLAUDE_CODE_AUTO_COMPACT_WINDOW, CLAUDE_CODE_SIMPLE, CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING) are unrelated to authentication, so the failure mode gives no hint about the root cause. I spent several hours doing clean reinstalls, Keychain wipes, and full configuration resets before identifying the env block as the trigger.

Code Example



---

"env": {
     "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "400000",
     "CLAUDE_CODE_SIMPLE": "1",
     "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Setting any CLAUDE_CODE_* variables inside the env object of ~/.claude/settings.json completely breaks OAuth authentication. /login reports success and writes a valid token to the macOS Keychain, but every subsequent command — interactive and -p — returns Not logged in · Please run /login.

The same variables set via shell export (or inline VAR=value claude) do not break auth. The issue is specific to how settings.env is loaded during startup.

This is especially confusing because the variables involved (CLAUDE_CODE_AUTO_COMPACT_WINDOW, CLAUDE_CODE_SIMPLE, CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING) are unrelated to authentication, so the failure mode gives no hint about the root cause. I spent several hours doing clean reinstalls, Keychain wipes, and full configuration resets before identifying the env block as the trigger.

What Should Happen?

env entries in settings.json that are unrelated to authentication should not affect credential loading. At minimum, if this is an intended interaction, there should be a clear error message pointing to settings.env as the cause rather than a generic Not logged in.

Error Messages/Logs

Steps to Reproduce

  1. Fresh install of Claude Code on macOS (native installer), authenticated via /login with a subscription — confirmed working.
  2. Add to ~/.claude/settings.json:
"env": {
     "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "400000",
     "CLAUDE_CODE_SIMPLE": "1",
     "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
}
  1. Start claude (any mode) — all commands return Not logged in · Please run /login.
  2. Run /login again — flow completes successfully, Keychain entry updated (confirmed via security find-generic-password -s "Claude Code-credentials", cdat reflects current time).
  3. Still: Not logged in on every command.
  4. Remove the env block from settings — authentication immediately works again, no re-login required.
  5. Set the same variables via shell (export CLAUDE_CODE_SIMPLE=1 etc. in ~/.zshrc, or inline CLAUDE_CODE_SIMPLE=1 claude) — auth works normally.

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

version: 2.1.97 (npm/Homebrew), also reproduced on 2.1.112 (native)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by removing the env block from ~/.claude/settings.json or setting the variables via shell export instead of through the settings.json file.

Guidance

  • Verify that the env block in ~/.claude/settings.json is the cause of the issue by removing it and checking if authentication works.
  • Try setting the variables via shell export (e.g., export CLAUDE_CODE_SIMPLE=1) to see if authentication works with the variables set.
  • Check the documentation for Claude Code to see if there are any known issues or limitations with setting environment variables through the settings.json file.
  • If the issue persists, try resetting the Claude Code configuration to its default state and re-adding the env block to isolate the problem.

Example

No code snippet is provided as the issue is related to configuration and environment variables.

Notes

The issue seems to be specific to how the env block is loaded during startup, and setting the variables via shell export does not cause the issue. The root cause of the problem is unclear, but removing the env block or setting the variables via shell export can serve as a workaround.

Recommendation

Apply workaround: Remove the env block from ~/.claude/settings.json or set the variables via shell export, as this has been shown to resolve the issue in the provided test cases.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] env in ~/.claude/settings.json breaks OAuth authentication on macOS [1 participants]