Skip to content

fix(init): expand ~ in config-dir overrides and reject relative ones - #4261

Closed
mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/init-config-dir-override
Closed

mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/init-config-dir-override

Conversation

@mrhard9090

@mrhard9090 mrhard9090 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4247

  • resolve_config_dir returned $CLAUDE_CONFIG_DIR (and $CODEX_HOME, $COPILOT_HOME, $HERMES_HOME, which share it) exactly as given. A literal ~ that no shell expanded, for example from a quoted value or an env file, made rtk init -g fail with Failed to create temp file in ~/.claude or write under ./~. A relative value such as .claude wrote into the current project while reporting a global install.
  • A leading ~ is now expanded against the home directory. A value that is still relative (.claude, or ~user/...) is rejected with $CLAUDE_CONFIG_DIR must be an absolute path, got ..., naming the variable that was set. The check uses has_root(), so Git Bash style /c/... values and the existing /custom/... test paths keep working on Windows.
  • test_resolve_hermes_home_prefers_hermes_home asserted the old pass-through of a literal ~/custom hermes home, which is the case this issue describes, so it now expects the expanded path.

Test plan

  • New test_resolve_claude_dir_expands_a_literal_tilde and test_resolve_claude_dir_rejects_a_relative_override.
  • cargo fmt --all && cargo clippy --all-targets -- -D warnings (clean) && cargo test --bin rtk on Windows (MSVC): 3743 passed, 2 failed. find_cmd::run_from_args_propagates_find_exit_status and stream::test_read_lines_lossy_preserves_lines_after_invalid_utf8 fail the same way on develop on this machine.

Written with help from Claude Opus 5.5.

resolve_config_dir returned CLAUDE_CONFIG_DIR, CODEX_HOME, COPILOT_HOME and HERMES_HOME as given. A ~ that no shell expanded made rtk init fail or write under ./~, and a relative value wrote into the current project while reporting a global install. Expand a leading ~ against the home directory and reject a path that is still relative, naming the variable.

Fixes rtk-ai#4247
@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working config init labels Sep 26, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk init failing when config-dir environment overrides (CLAUDE_CONFIG_DIR, CODEX_HOME, COPILOT_HOME, HERMES_HOME) contain a literal, unexpanded ~, and now rejects overrides that remain relative after expansion. Error messages now name the specific variable that was set, and a Hermes test that had encoded the old passthrough behavior was updated to expect the expanded path.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4247


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your time on this, and for the care that went into the tests and the error messages. I'm sorry: the issue you implemented was wrong, and that's on me.

Claude Code uses CLAUDE_CONFIG_DIR exactly as set, with no ~ expansion and no absolute-path check, in every release from 0.2.9 to the current one. A relative value resolves against the directory it was launched from. What develop does today, writing to ./~/.claude, is therefore where Claude Code reads. On this branch, measured against develop:

  • rtk init -g installs the hook into $HOME/.claude, where Claude Code does not look.
  • The hook stops seeing a deny rule placed where Claude Code reads it (git status under Bash(git status) gets rewritten to rtk git status).
  • --uninstall no longer finds the installed hook.

I've closed #4247 as not planned, so I'm closing this PR as well. The one real defect that turned up is tracked in #4676, if it interests you.

@KuSh KuSh closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working config init

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init: CLAUDE_CONFIG_DIR is used as given when relative or holding a literal ~

3 participants