Skip to content

fix(config): resolve Claude Code's config dir by its own home rule - #4262

Merged
max-sixty merged 1 commit into
max-sixty:mainfrom
hiro-nikaitou:fix/claude-config-dir-home-rule
Sep 26, 2026
Merged

max-sixty merged 1 commit into
max-sixty:mainfrom
hiro-nikaitou:fix/claude-config-dir-home-rule

Conversation

@hiro-nikaitou

Copy link
Copy Markdown
Contributor

wt config plugins claude install-statusline and wt config show resolved Claude Code's config directory with a HOME-first home rule, while Claude Code itself — and every other home lookup in worktrunk — uses the OS lookup. On Windows the two disagree whenever HOME holds the POSIX-style path Git Bash, MSYS2 and Cygwin set, and the disagreement is silent in both directions.

Problem

src/commands/config/show.rs::home_dir read HOME, then USERPROFILE, before falling back to worktrunk::path::home_dir. Claude Code is a Node program: its config directory is process.env.CLAUDE_CONFIG_DIR || os.homedir(), and Node's os.homedir() on Windows reads USERPROFILE and ignores HOME entirely. In a Git Bash session HOME is /c/Users/<name>, which is not a Windows path at all — Windows resolves it against the current drive's root.

So install-statusline reports ✓ Statusline configured after writing to a directory Claude Code never opens, and wt config show reports a statusline that is configured as missing. wt config show reads back from the same path install just wrote to, so the two agree with each other and neither agrees with Claude Code.

Evidence

Windows 11, two binaries built from the same tree with cargo +stable-x86_64-pc-windows-gnu build — one at main (f88b827c), one with this change — run in an identical environment: HOME=/c/…/posix, USERPROFILE=D:\…\real, CLAUDE_CONFIG_DIR unset.

=== BEFORE  upstream main f88b827c
USERPROFILE=D:\…\wt-evidence-before\real
HOME=/c/projects/…/wt-evidence-before/posix
install-statusline -> ✓ Statusline configured (exit=0)
settings.json at USERPROFILE\.claude: False
settings.json at POSIX-HOME mirror: True

=== AFTER   this branch
USERPROFILE=D:\…\wt-evidence-after\real
HOME=/c/projects/…/wt-evidence-after/posix
install-statusline -> ✓ Statusline configured (exit=0)
settings.json at USERPROFILE\.claude: True
settings.json at POSIX-HOME mirror: False

The mirror is D:\c\projects\…\posix\.claude\settings.json — the POSIX path re-rooted on whichever drive wt happened to run from.

Detection, with the statusline already where Claude Code reads it:

=== BEFORE  upstream main f88b827c (statusline already configured)
wt config show -> ↳ Statusline not configured. To configure, run wt config plugins claude install-statusline

=== AFTER   this branch (statusline already configured)
wt config show -> ✓ Statusline configured

Claude Code's rule, read off the installed bundle (its config path is join(process.env.CLAUDE_CONFIG_DIR || os.homedir(), ".claude…json")) and confirmed against Node on the same machine with HOME set to something else:

$ node -e "console.log(require('os').homedir())"
C:\Users\35417

What changes

claude_config_dir() resolves all three of its branches through worktrunk::path::home_dir(), and the module-local home_dir() is deleted. On Unix nothing moves — the home crate is HOME there, with the passwd entry behind it, exactly as os.homedir() is. It is the rule pi.rs and omp.rs already use for their agent directories, which is the point: the value being resolved is a third party's directory, so the rule that matters is the one that third party uses. Item 9 of the survey in #4106 flagged the two rules in this module as needing a call; this settles it.

The tilde branch keeps the behaviour the previous change settled: ~/x and a bare ~ expand against home, and ~\x stays a real path component. It now expands by the same rule rather than a second one.

Verification

  • cargo test --test integration test_plugins_claude_install_statusline → 9 passed (honors_claude_config_dir, expands_tilde_in_claude_config_dir both cases, falls_back_to_dot_claude, and the five others)
  • the two binaries and the before/after above
  • cargo fmt --check, cargo check --all-targets

Not covered by a test: set_temp_home_env pins HOME and USERPROFILE to the same temp path, so the suite cannot distinguish the two rules, and the manual evidence above is where the difference shows. The fixture would need to split them for a regression test.

`show.rs::home_dir` read `HOME` before `USERPROFILE`, while Claude Code
resolves its config directory with `os.homedir()` — `USERPROFILE` on
Windows, where the POSIX-style `HOME` Git Bash sets is not a Windows path
at all. `install-statusline` wrote settings.json beside the drive root and
reported success; `wt config show` reported a configured statusline as
missing. All three branches now use `worktrunk::path::home_dir()`, the rule
the other agent integrations already use.

Signed-off-by: hiro-nikaitou <[email protected]>
@max-sixty
max-sixty merged commit 48d9256 into max-sixty:main Sep 26, 2026
38 checks passed
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.

3 participants