Environment variables had to be `unset` to recognize correct plan

Resolved 💬 6 comments Opened Jul 23, 2025 by mikedotexe Closed Jan 3, 2026

[Original] Bug Description
Darn, I've tried quite a bit, but cannot get my MAX plan to use Opus 4. Claude Code believes I have a Pro account instead. I tried logging out, logging in, claude setup-token, checking my env vars, echoing them. I think there's a bug here, friends. Great work, this thing is amazing

---

Extended thoughts

UPDATE: so I was able to get it to recognize the MAX plan, and think I have some useful information I'll share while it's in my head.

I'll explain this how I'm imagining it after several attempts, and present it as such. I'll admit I don't know this codebase, but maybe it'll help anway.

So there seems to be two ways I was trying to accomplish this, and perhaps this is why I encountered this "bug" that I now believe to be partially (or perhaps fully) my fault.

First (setup-token CLI command)

On my terminal, I have run claude setup-token, which finishes by displaying the CLAUDE_CODE_OAUTH_TOKEN with instructions. So in my bash file (for me ~/.zshrc) I added:

export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-…

And along the way in my journey, I also had two other environment variables in there:

  • CLAUDE_CODE_MAX_OUTPUT_TOKENS
  • ANTHROPIC_MODEL

Second (/login command)

After running claude and entering the interactive mode, there is a slash command /login that seems to do similar work as the CLI's setup-token except it doesn't print the OAuth token, it just tells you it's finished.

My solution

I was trying /logout and /login and it seems that the CLI setup-token command might have interfered with what I should have stuck to, which is the /login interactive command.

The silly mistake I made was to comment out the Anthropic-related env vars, and source my bash file. But I forgot to unset the env vars, so I could still echo $CLAUDE_CODE_OAUTH_TOKEN and see it. After running:

unset CLAUDE_CODE_OAUTH_TOKEN
unset CLAUDE_CODE_MAX_OUTPUT_TOKENS
unset ANTHROPIC_MODEL

I was able to use /login and when I ran the /status command, confirmed that it had successfully recognized my plan.

Potential leads to fix

First, this may be an obscure problem I ran into. It might also be some low-hanging fruit if there's some logic in here that checks environment variable values and compares them against incorrect account plan information. So perhaps there's more being done while validating env vars than should be.

Another potential consideration is whether we want to have two avenues for linking your account. It seems reasonable to consider removing the CLI setup-token command, or deprecate it with a message saying, "Run claude and use the /login command to connect your account, please. Friendly deprecation notice."

---

Assets

<img width="2619" height="1019" alt="Image" src="https://github.com/user-attachments/assets/88a7aa72-554a-4113-9969-5b135765beb1" />

---

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 1.0.58
  • Feedback ID:

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:child_process:959:22)\n    at checkExecSyncError (node:child_process:458:27)\n    at execSync (node:child_process:278:31)\n    at eY (/$bunfs/root/claude:687:5945)\n    at <anonymous> (/$bunfs/root/claude:583:5727)\n    at W (/$bunfs/root/claude:435:14413)\n    at f3 (/$bunfs/root/claude:583:3474)\n    at xK (/$bunfs/root/claude:583:2341)\n    at X2 (/$bunfs/root/claude:583:8262)\n    at sHZ (/$bunfs/root/claude:583:8420)","timestamp":"2025-07-23T04:25:24.599Z"},{"error":"Error: Command failed: security delete-generic-password -a $USER -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:child_process:959:22)\n    at checkExecSyncError (node:child_process:458:27)\n    at execSync (node:child_process:278:31)\n    at eY (/$bunfs/root/claude:687:5945)\n    at aHZ (/$bunfs/root/claude:583:6754)\n    at rHZ (/$bunfs/root/claude:583:6660)\n    at bB1 (/$bunfs/root/claude:1752:2567)\n    at startOAuthFlow (/$bunfs/root/claude:1752:3766)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-07-23T04:25:41.963Z"},{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:child_process:959:22)\n    at checkExecSyncError (node:child_process:458:27)\n    at execSync (node:child_process:278:31)\n    at eY (/$bunfs/root/claude:687:5945)\n    at <anonymous> (/$bunfs/root/claude:583:5727)\n    at W (/$bunfs/root/claude:435:14413)\n    at f3 (/$bunfs/root/claude:583:3474)\n    at xK (/$bunfs/root/claude:583:2341)\n    at X2 (/$bunfs/root/claude:583:8262)\n    at tu (/$bunfs/root/claude:599:5583)","timestamp":"2025-07-23T04:25:42.014Z"},{"error":"Error\n    at Hq (/$bunfs/root/claude:466:1076)\n    at B1 (/$bunfs/root/claude:467:9963)\n    at emit (node:events:92:22)\n    at endReadableNT (internal:streams/readable:862:50)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/claude:469:2098)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-07-23T04:27:06.651Z"}]

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗