Repository navigation
fix(init): expand ~ in config-dir overrides and reject relative ones - #4261
mrhard9090 wants to merge 1 commit into
Conversation
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
📊 Automated PR Analysis
SummaryFixes rtk init failing when config-dir environment overrides (CLAUDE_CONFIG_DIR, CODEX_HOME, COPILOT_HOME, HERMES_HOME) contain a literal, unexpanded Review Checklist
Linked issues: #4247 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
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
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. |
Summary
Fixes #4247
resolve_config_dirreturned$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, madertk init -gfail withFailed to create temp file in ~/.claudeor write under./~. A relative value such as.claudewrote into the current project while reporting a global install.~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 useshas_root(), so Git Bash style/c/...values and the existing/custom/...test paths keep working on Windows.test_resolve_hermes_home_prefers_hermes_homeasserted 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
test_resolve_claude_dir_expands_a_literal_tildeandtest_resolve_claude_dir_rejects_a_relative_override.cargo fmt --all && cargo clippy --all-targets -- -D warnings(clean)&& cargo test --bin rtkon Windows (MSVC): 3743 passed, 2 failed.find_cmd::run_from_args_propagates_find_exit_statusandstream::test_read_lines_lossy_preserves_lines_after_invalid_utf8fail the same way ondevelopon this machine.Written with help from Claude Opus 5.5.