Skip to content

fix(init): create Claude config dir for global init - #2518

Closed
elite133713 wants to merge 1 commit into
rtk-ai:developfrom
elite133713:fix/init-create-claude-config-dir
Closed

elite133713 wants to merge 1 commit into
rtk-ai:developfrom
elite133713:fix/init-create-claude-config-dir

Conversation

@elite133713

@elite133713 elite133713 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • create the Claude config parent directory before global init writes RTK.md or settings.json
  • fix fresh-home failures where atomic writes could not create temp files inside a missing ~/.claude directory
  • add regression coverage for default global init, hook-only global init, and dry-run behavior with a missing Claude config dir

Fixes #2519.

Context

Plain global init can currently fail on a fresh machine or user profile when ~/.claude does not exist:

rtk: Failed to write RTK.md: ~/.claude/RTK.md: Failed to create temp file in ~/.claude: No such file or directory (os error 2)

The underlying issue is that atomic_write() creates its tempfile inside the target file's parent directory. That parent directory must exist before NamedTempFile::new_in(parent) is called.

Related: #1840 fixes the separate Cursor-only path for rtk init -g --agent cursor and missing ~/.cursor. This PR intentionally stays focused on the default/global Claude init path.

CONTRIBUTING.md alignment

  • Focused PR: one bug fix in the hook init path; no unrelated refactors or formatting churn.
  • Conventional commit: fix(init): create Claude config dir for global init.
  • Target branch: develop.
  • Documentation: not updated because this is a bug fix for existing documented init behavior, not a new hook feature or behavior surface.
  • Changelog: not edited manually; release-please owns it.

Test plan

  • Unit tests added/updated for changed code
  • Edge cases covered: missing Claude config dir, hook-only global init, dry-run with missing dir
  • cargo fmt --all --check
  • cargo test missing_claude_dir -- --nocapture
  • cargo test --all (2212 passed, 8 ignored)
  • cargo clippy --all-targets -- -D warnings
  • Manual test with temp HOME and CLAUDE_CONFIG_DIR: ./target/debug/rtk init -g --auto-patch
  • Snapshot tests not applicable: no snapshots changed
  • Token savings/truncation checklist not applicable: this PR does not add or change output filters

@CLAassistant

CLAassistant commented Jun 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@elite133713
elite133713 force-pushed the fix/init-create-claude-config-dir branch from 5282cad to 408f132 Compare June 19, 2026 23:37
@elite133713

Copy link
Copy Markdown
Contributor Author

Closing and recreating this PR so the commits use my GitHub no-reply author identity instead

@elite133713
elite133713 deleted the fix/init-create-claude-config-dir branch June 19, 2026 23:37
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.

bug(init): global Claude init fails when ~/.claude is missing

2 participants