Skip to content

fix(init): preserve settings.json symlink and portable hook path - #675

Closed
TechWizard9999 wants to merge 1 commit into
rtk-ai:developfrom
TechWizard9999:fix/init-preserve-settings-symlink
Closed

TechWizard9999 wants to merge 1 commit into
rtk-ai:developfrom
TechWizard9999:fix/init-preserve-settings-symlink

Conversation

@TechWizard9999

Copy link
Copy Markdown
Contributor

Description

This fixes two global rtk init problems when patching Claude settings:

  1. symlinked settings.json was replaced by a regular file
  2. hook command entries were written as machine-specific absolute paths

Related Issue

Closes #653

Changes Made

  • updated atomic write path resolution to detect symlink targets and write through to the target file (preserving the symlink itself)
  • switched hook command insertion to a portable shell expression:
    • ${CLAUDE_CONFIG_DIR:-$HOME/.claude}/hooks/rtk-rewrite.sh
  • updated manual settings patch snippet to use the same portable hook command
  • added targeted tests for symlink-preserving atomic writes and portable hook command generation
  • added changelog entry under Unreleased bug fixes

Files Changed

Testing

  • cargo fmt --all --check
  • rtk cargo clippy --all-targets (2 pre-existing warnings in untouched files)
  • rtk cargo test
  • rtk cargo test init::tests::test_atomic_write_preserves_symlink
  • rtk cargo test init::tests::test_hook_command_for_settings_uses_portable_path

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated
  • No breaking changes introduced

cc @pszymkowiak for review

@CLAassistant

CLAassistant commented Mar 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

@pszymkowiak could you please review this and let me know if anything needs to change?

@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@TechWizard9999
TechWizard9999 force-pushed the fix/init-preserve-settings-symlink branch from 88f4825 to b8c18c6 Compare March 27, 2026 01:48
@TechWizard9999

Copy link
Copy Markdown
Contributor Author

Rebased on latest develop per the refactor notice and force-updated this branch.

@pszymkowiak could you please re-review when convenient?

@TechWizard9999
TechWizard9999 force-pushed the fix/init-preserve-settings-symlink branch from b8c18c6 to eeb6eda Compare March 30, 2026 03:20
@TechWizard9999
TechWizard9999 force-pushed the fix/init-preserve-settings-symlink branch from eeb6eda to 4bf48a1 Compare April 15, 2026 14:10
@TechWizard9999

Copy link
Copy Markdown
Contributor Author

Rebased on latest develop and force-pushed with conflict resolution in init path handling.\n\nRetested the related symlink/portable-hook behavior.\n\n@pszymkowiak @FlorianBruniaux please re-review when convenient.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

Quick maintainer ping after latest rebase update. @pszymkowiak @FlorianBruniaux please re-review when convenient.

@ChrisGVE

ChrisGVE commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Together with PR #674 this feature is to me critical. I can imagine that everybody is busy, but these have been opened for a month and I am sure that I am not the only one waiting for these features to be merged into rtk @FlorianBruniaux @pszymkowiak

Thanks all for your efforts on a stellar product.

@miteshashar

Copy link
Copy Markdown

This issue is prevalent across the repo. The symlink replacement happened for not just my Claude settings.json file, but also my Codex AGENTS.md

@ChrisGVE

Copy link
Copy Markdown
Contributor

Again this issue is key for many of us and it seems simple enough to address. I know that a lot of good work goes into rtk, but this has been pending for way too long. Could the maintainer take care of it as well as PR #674 which is as crucial.

@KuSh

KuSh commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Hi, closed in favor of #2088.

@KuSh KuSh closed this May 31, 2026
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.

"rtk init --global" breaks symlink

6 participants