Bug report
Summary
rtk init -g fails on a fresh user profile when the Claude config directory does not already exist.
The failure occurs before RTK can create RTK.md because the atomic write implementation creates a temporary file inside the target file's parent directory, and that parent directory is missing.
Steps to reproduce
Run global init on a machine or temp home where ~/.claude does not exist:
rm -rf ~/.claude
rtk init -g
Equivalent isolated reproduction:
tmp=$(mktemp -d)
HOME="$tmp/home" CLAUDE_CONFIG_DIR="$tmp/.claude" rtk init -g --auto-patch
Actual behavior
rtk: Failed to write RTK.md: /Users/rm-rf/.claude/RTK.md: Failed to create temp file in /Users/rm-rf/.claude: No such file or directory (os error 2)
Expected behavior
rtk init -g should create the missing Claude config directory and then write:
~/.claude/RTK.md
~/.claude/CLAUDE.md
~/.claude/settings.json when patching is enabled
Dry-run mode should continue to report intended writes without creating the directory.
Cause
atomic_write() uses NamedTempFile::new_in(parent), so callers that write into global config paths must ensure the parent directory exists before attempting the atomic write.
Fix PR
Proposed fix: #2518
Related but separate: #1840 addresses the Cursor-only rtk init -g --agent cursor path and missing ~/.cursor; this issue is for plain/global Claude init with missing ~/.claude.
Validation in PR #2518
- Added regression tests for missing Claude config dir in default global init, hook-only global init, and dry-run.
cargo fmt --all --check
cargo test missing_claude_dir -- --nocapture
cargo test --all (2212 passed, 8 ignored)
cargo clippy --all-targets -- -D warnings
- Manual temp-home check:
./target/debug/rtk init -g --auto-patch
Bug report
Summary
rtk init -gfails on a fresh user profile when the Claude config directory does not already exist.The failure occurs before RTK can create
RTK.mdbecause the atomic write implementation creates a temporary file inside the target file's parent directory, and that parent directory is missing.Steps to reproduce
Run global init on a machine or temp home where
~/.claudedoes not exist:rm -rf ~/.claude rtk init -gEquivalent isolated reproduction:
Actual behavior
Expected behavior
rtk init -gshould create the missing Claude config directory and then write:~/.claude/RTK.md~/.claude/CLAUDE.md~/.claude/settings.jsonwhen patching is enabledDry-run mode should continue to report intended writes without creating the directory.
Cause
atomic_write()usesNamedTempFile::new_in(parent), so callers that write into global config paths must ensure the parent directory exists before attempting the atomic write.Fix PR
Proposed fix: #2518
Related but separate: #1840 addresses the Cursor-only
rtk init -g --agent cursorpath and missing~/.cursor; this issue is for plain/global Claude init with missing~/.claude.Validation in PR #2518
cargo fmt --all --checkcargo test missing_claude_dir -- --nocapturecargo test --all(2212 passed, 8 ignored)cargo clippy --all-targets -- -D warnings./target/debug/rtk init -g --auto-patch