fix: rtk init -g --agent cursor fails when ~/.claude directory is missing#3014
Open
mvanhorn wants to merge 1 commit into
Open
fix: rtk init -g --agent cursor fails when ~/.claude directory is missing#3014mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The single choke point is
atomic_write(path, content)insrc/hooks/init.rs: it computesparent = target.parent()and immediately callsNamedTempFile::new_in(parent), which returnsos error 2whenparentdoes not exist. Every other write site in this file already callsfs::create_dir_all(...)before writing (e.g.Why this matters
Running
rtk init -g --agent cursor(global install targeting Cursor) crashes withFailed 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~/.claudedirectory. 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.claudedirectory 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
atomic_write(or global default init via a tempCLAUDE_CONFIG_DIRwhose.claudesubdir does not yet exist) creates the missing parent directory and writes the file successfully, mirroring the existingtest_default_mode_creates_rtk_mdpattern.write_if_changedno-op-when-unchanged path).Fixes #3009
AI was used for assistance.