Skip to content

fix: rtk init -g --agent cursor fails when ~/.claude directory is missing#3014

Open
mvanhorn wants to merge 1 commit into
rtk-ai:developfrom
mvanhorn:fix/3009-init-agent-missing-claude-dir
Open

fix: rtk init -g --agent cursor fails when ~/.claude directory is missing#3014
mvanhorn wants to merge 1 commit into
rtk-ai:developfrom
mvanhorn:fix/3009-init-agent-missing-claude-dir

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

The single choke point is atomic_write(path, content) in src/hooks/init.rs: it computes parent = target.parent() and immediately calls NamedTempFile::new_in(parent), which returns os error 2 when parent does not exist. Every other write site in this file already calls fs::create_dir_all(...) before writing (e.g.

Why this matters

Running rtk init -g --agent cursor (global install targeting Cursor) crashes with Failed to write RTK.md: .../.claude/RTK.md: Failed to create temp file in .../.claude: No such file or directory (os error 2) whenever the user does not already have a ~/.claude directory. It is reproduced on rtk 0.43.0 on macOS 15.7.3, macOS 26.5.1, and Arch Linux by three separate reporters. The reporter confirms that manually creating a .claude directory makes the command succeed, so the failure is purely the missing parent directory. Because the global default path also installs Claude Code awareness files (Cursor hooks are additive on top of Claude Code) and fails fast on that first write, the Cursor portion never runs.

Testing

  • Happy path: atomic_write (or global default init via a temp CLAUDE_CONFIG_DIR whose .claude subdir does not yet exist) creates the missing parent directory and writes the file successfully, mirroring the existing test_default_mode_creates_rtk_md pattern.
  • Idempotence / existing dir: writing when the parent directory already exists still succeeds and overwrites atomically (no regression to the existing atomic-rename behavior or the write_if_changed no-op-when-unchanged path).
  • Error path: writing to a path with no parent (root) still returns the existing "path has no parent directory" error, and a genuinely unwritable parent still surfaces a contextual error rather than panicking.

Fixes #3009

AI was used for assistance.

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.

wont install for Cursor - trys to install Claude v 0.43.0

1 participant