Local installation detection ignores CLAUDE_CONFIG_DIR environment variable
Summary
Claude Code's installation detection logic does not respect the CLAUDE_CONFIG_DIR environment variable when determining if a local installation exists, leading to false "npm-global" detection even when running from a valid local installation.
Use Case
I have separate Claude Code installations for my work and personal accounts, each with their own CLAUDE_CONFIG_DIR to keep projects and settings isolated.
Environment
- Claude Code version: 1.0.43
- OS: Linux (Ubuntu on WSL2)
- Node: v22.14.0 (via nvm)
Steps to Reproduce
- Set up separate local installations for work and personal accounts:
```bash
# Work account
export CLAUDE_CONFIG_DIR=/home/steve/claude-work
claude migrate-installer
# Personal account
export CLAUDE_CONFIG_DIR=/home/steve/claude-personal
claude migrate-installer
```
- Create aliases to run each installation:
``bash``
alias claude-work="CLAUDE_CONFIG_DIR=/home/steve/claude-work /home/steve/claude-work/local/claude"
alias claude-personal="CLAUDE_CONFIG_DIR=/home/steve/claude-personal /home/steve/claude-personal/local/claude"
- Run doctor command on either installation:
``bash``
claude-work /doctor
Expected Behavior
- Claude should detect it's running from a local installation at
$CLAUDE_CONFIG_DIR/local - Doctor output should show "Currently running: local"
- No warnings about "Local installation exists but not being used"
Actual Behavior
Claude CLI Diagnostic
Currently running: npm-global (1.0.43)
Path: /home/steve/.nvm/versions/node/v22.14.0/bin/node
Invoked: /home/steve/claude-work/local/node_modules/@anthropic-ai/claude-code/cli.js
Config install method: local
Warning: Local installation exists but not being used
Fix: Consider using local installation: claude migrate-installer
Root Cause
The detection logic appears to only check for local installations in the default ~/.claude/local location, ignoring the CLAUDE_CONFIG_DIR environment variable. However, migrate-installer correctly respects CLAUDE_CONFIG_DIR and installs to $CLAUDE_CONFIG_DIR/local.
This creates an inconsistency where:
- migrate-installer installs to:
$CLAUDE_CONFIG_DIR/local - Detection logic only looks for:
~/.claude/local(ignoring CLAUDE_CONFIG_DIR)
Impact
Users who need multiple Claude Code installations (e.g., for work/personal separation, different organizations, or multiple accounts) cannot properly use local installations with auto-updates enabled. The tool always reports as "npm-global" even when running from valid local installations created by migrate-installer.
Suggested Fix
Update the installation detection logic to:
- If
CLAUDE_CONFIG_DIRis set, check for local installation at$CLAUDE_CONFIG_DIR/local - Otherwise, fall back to the default
~/.claude/local
This would make the detection logic consistent with migrate-installer's behavior and support the multi-account use case properly.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗