claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] claude on Mac deletes the .credentials.json file that claude on Linux uses

Open seekayel opened this issue 2 months ago • 4 comments

Preflight Checklist

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

What's Wrong?

(bug #1414 was closed due to inactivity but core workflow issue remains. this is an extension of that with workflow description)

To get the most out of claude I run in a container with --dangerously-skip-permissions. This lets me leverage the full power of the agent while protecting my development machine. To do this I create a container with needed dev cli tools and mount in claude config files from my home directory (code for reference gh:seekayel/yolo

My base machine is macOS and the container is Ubuntu.

When I login to claude on my mac my credentials are stored into my keychain and the credentials file in $HOME gets deleted.

I have tried to reading my credentials out of my keychain before launching the container with security find-generic-password -s "Claude Code-credentials" -w > $HOME/.claude/credentials.json but the containerized claude --dangerously-skip-permissions still isn't finding (or honoring?) the $HOME/.claude/credentials.json this means I have to login each time.

This seems like a use case that is intended to be supported given the reference implementation: https://github.com/anthropics/claude-code/tree/main/.devcontainer but with CLI only setup.

What Should Happen?

claude should provide a way to do one of the following:

  • keep credentials.json on disk aka don't shuffle into macOS keychain
  • write temporary credentials.json to disk that can be used in a docker (or devcontainer?)
  • not require login each time?

Error Messages/Logs


Steps to Reproduce

  1. write macOS keychain credentials back to file:

security find-generic-password -s "Claude Code-credentials" -w > "$HOME/.claude/credentials.json"

  1. Build container
docker build -t repo-credentials -f - . <<EOF
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN apt-get update && apt-get install -y nodejs npm
RUN npm install -g @anthropic-ai/claude-code
EOF
  1. Run container docker run -it --rm --name repo-credentials -v "$HOME/.claude:/root/.claude" repo-credentials

  2. Verify credentials file exists and is mounted cat /root/.claude/credentials.json

  3. See claude not pickup credentials claude

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.0.24 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

seekayel avatar Oct 21 '25 10:10 seekayel