Skip to content

fix: write .claude.json to ~/.claude/ instead of homedir root - #1335

Closed
p2p3p wants to merge 1 commit into
claude-code-best:mainfrom
p2p3p:fix/claude-json-path
Closed

fix: write .claude.json to ~/.claude/ instead of homedir root#1335
p2p3p wants to merge 1 commit into
claude-code-best:mainfrom
p2p3p:fix/claude-json-path

Conversation

@p2p3p

@p2p3p p2p3p commented Aug 3, 2026

Copy link
Copy Markdown

将 .claude.json 写入路径从 homedir() 根目录改为 getClaudeConfigHomeDir() 对应的 ~/.claude/ 目录。

Summary by CodeRabbit

  • Bug Fixes
    • Improved configuration file discovery by honoring the configured settings directory when no explicit override is provided.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

getGlobalClaudeFile now uses getClaudeConfigHomeDir() as its fallback directory. The CLAUDE_CONFIG_DIR override and filename construction remain unchanged.

Changes

Configuration path resolution

Layer / File(s) Summary
Global file fallback
src/utils/env.ts
getGlobalClaudeFile uses getClaudeConfigHomeDir() when CLAUDE_CONFIG_DIR is not set.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related issues

  • b #1334 — Describes the same getGlobalClaudeFile() path-resolution bug.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes moving .claude.json writes from the home directory to the ~/.claude/ configuration directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/env.ts`:
- Around line 25-28: Update the directory argument in the configuration path
construction to use getClaudeConfigHomeDir() directly, removing the
process.env.CLAUDE_CONFIG_DIR || fallback expression. Preserve joining the
resolved directory with filename so empty environment values follow the helper’s
home-directory behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3dc5cd31-9f23-47fb-bdbf-468caedbb66a

📥 Commits

Reviewing files that changed from the base of the PR and between 2ccc216 and c72b7f5.

📒 Files selected for processing (1)
  • src/utils/env.ts

Comment thread src/utils/env.ts
Comment on lines +25 to +28
return join(
process.env.CLAUDE_CONFIG_DIR || getClaudeConfigHomeDir(),
filename,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use getClaudeConfigHomeDir() as the sole directory resolver.

When CLAUDE_CONFIG_DIR is set to an empty string, getClaudeConfigHomeDir() returns "" because it uses ??. The || expression therefore still yields "", and join("", filename) resolves to the current working directory instead of ~/.claude/. This can split or misplace the global configuration. Use the helper directly.

Proposed fix
   return join(
-    process.env.CLAUDE_CONFIG_DIR || getClaudeConfigHomeDir(),
+    getClaudeConfigHomeDir(),
     filename,
   )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/env.ts` around lines 25 - 28, Update the directory argument in the
configuration path construction to use getClaudeConfigHomeDir() directly,
removing the process.env.CLAUDE_CONFIG_DIR || fallback expression. Preserve
joining the resolved directory with filename so empty environment values follow
the helper’s home-directory behavior.

@p2p3p p2p3p closed this Aug 3, 2026
@p2p3p
p2p3p deleted the fix/claude-json-path branch August 3, 2026 20:35
@p2p3p
p2p3p restored the fix/claude-json-path branch August 3, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant