Skip to content

claude CLI works in interactive shell but fails in direct execution with Not logged in · Run /login #53

@BlockLune

Description

@BlockLune

When using Claude Code in Docker Sandboxes, environment variables are injected via a persistent shell script:

sbx exec -d your_sandbox_name bash -c "cat << 'EOF' > /etc/sandbox-persistent.sh
jq '. + {\"hasCompletedOnboarding\": true}' ~/.claude.json > /tmp/.claude.json && mv /tmp/.claude.json ~/.claude.json
export ANTHROPIC_BASE_URL=your_base_url
export ANTHROPIC_AUTH_TOKEN=your_key
unset ANTHROPIC_API_KEY
EOF"

Behavior observed:

  • sbx exec -it your_sandbox_name bash then running claude → works fine.
  • sbx exec -it your_sandbox_name claude → fails with Not logged in · Run /login.
  • sbx run claude → also fails with Not logged in · Run /login.

Expected behavior:

claude CLI should respect the environment variables and login state regardless of whether it is run inside an interactive shell or directly.

Additional context:

Run sbx run claude, then use ! to run external commands. I got this:

Image
  • OS: Fedora 43 (KDE Plasma Desktop Edition)
  • sbx Client Version: v0.25.0 20cff0e2d724ae7e2a5fcb5fa38e4d45f1432cc7
  • sbx Server Version: v0.25.0 20cff0e2d724ae7e2a5fcb5fa38e4d45f1432cc7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions