fix: change default config dir from ~/.claude to ~/.openclaude (#280)
Prevents collision with existing Claude Code installations that already use ~/.claude for their own config, settings, and project data. Migration compatibility: if ~/.openclaude does not yet exist but ~/.claude does, the legacy path is kept automatically so existing openclaude users don't lose their data on upgrade. New installs go straight to ~/.openclaude. Users who need an explicit path can set CLAUDE_CONFIG_DIR. Fixes #184 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import memoize from 'lodash-es/memoize.js'
|
import memoize from 'lodash-es/memoize.js'
|
||||||
|
import { existsSync } from 'fs'
|
||||||
import { homedir } from 'os'
|
import { homedir } from 'os'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
|
||||||
@@ -6,9 +7,18 @@ import { join } from 'path'
|
|||||||
// tests that change the env var get a fresh value without explicit cache.clear.
|
// tests that change the env var get a fresh value without explicit cache.clear.
|
||||||
export const getClaudeConfigHomeDir = memoize(
|
export const getClaudeConfigHomeDir = memoize(
|
||||||
(): string => {
|
(): string => {
|
||||||
return (
|
if (process.env.CLAUDE_CONFIG_DIR) {
|
||||||
process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude')
|
return process.env.CLAUDE_CONFIG_DIR.normalize('NFC')
|
||||||
).normalize('NFC')
|
}
|
||||||
|
const newDefault = join(homedir(), '.openclaude')
|
||||||
|
// Migration compatibility: if ~/.openclaude doesn't exist yet but ~/.claude
|
||||||
|
// does, keep using ~/.claude so existing users don't lose their data on
|
||||||
|
// upgrade. New installs (neither dir exists) go straight to ~/.openclaude.
|
||||||
|
const legacyPath = join(homedir(), '.claude')
|
||||||
|
if (!existsSync(newDefault) && existsSync(legacyPath)) {
|
||||||
|
return legacyPath.normalize('NFC')
|
||||||
|
}
|
||||||
|
return newDefault.normalize('NFC')
|
||||||
},
|
},
|
||||||
() => process.env.CLAUDE_CONFIG_DIR,
|
() => process.env.CLAUDE_CONFIG_DIR,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user