Repository navigation
fix(shell): resolve fish's config directory once, so the wrapper lands where fish reads it - #4107
Conversation
…s where fish reads it The fish wrapper path was hardcoded to ~/.config/fish/functions while the fish completion path resolved the XDG config directory, so a non-default $XDG_CONFIG_HOME split the two: install wrote the wrapper where fish never looks and reported success. Route the wrapper, the completion and the deprecated conf.d path through one fish_config_dir() helper. Refs #4106
worktrunk-bot
left a comment
There was a problem hiding this comment.
Self-review. The consolidation is the right shape and the wrapper/completion split it fixes is real, but the diff stops three call sites short of its own thesis, and retargeting legacy_fish_conf_d_path moves an unread deletion onto a directory worktrunk has never written to.
wt config shell uninstall fish can no longer find what install writes
The helper's docstring says every fish path goes through it, but scan_for_uninstall in src/commands/configure_shell.rs still builds fish's directories by hand — let functions_dir = home.join(".config").join("fish").join("functions"); and the confd_dir beside it — as does the completions_dir a few dozen lines below in the same function, and the two fish entries in scan_for_detection_details (src/shell/detection.rs, the // Fish functions/ (current location) block).
So under a custom $XDG_CONFIG_HOME, after this PR: install writes $XDG_CONFIG_HOME/fish/functions/wt.fish, and wt config shell uninstall fish scans ~/.config/fish/functions, matches nothing, reports the shell as not found, and leaves the wrapper loaded. That turns the bug from "install goes somewhere inert" into "install works, uninstall silently can't undo it" — arguably worse for the user, because the first state is visibly broken and the second isn't.
The scan_for_detection_details hardcode has a second effect: config/show.rs decides legacy_fish_has_integration by comparing a detection result's path against Shell::legacy_fish_conf_d_path. After this PR those are resolved by two different rules, so for custom-$XDG_CONFIG_HOME users they can never be equal and the "integration lives at the deprecated location" row stops firing.
Retargeting the conf.d path changes what install deletes
Worktrunk has only ever written the conf.d file at ~/.config/fish/conf.d/{cmd}.fish — hardcoded since d378fa7e7, and the docstring three lines above the change still says so. Routing it through fish_config_dir has two consequences for a user with a custom $XDG_CONFIG_HOME:
- The cleanup stops looking where worktrunk's stranded file actually is, so it no longer removes the one file it exists to remove.
cleanup_legacy_fish_conf_dnowfs::remove_files$XDG_CONFIG_HOME/fish/conf.d/{cmd}.fish— a path fish does read and worktrunk has never written. Its docstring justifies removing the file whole and unread on the grounds that "the path names the file worktrunk owns"; that rested on worktrunk having put it there. A user's ownwt.fishin their live fishconf.dis now deleted bywt config shell install fish, without its contents being read.
This is the deletion surface .claude/skills/running-tend/references/review-pr.md holds for a human: the command is wt config shell install fish and the file is src/commands/configure_shell.rs (cleanup_legacy_fish_conf_d). @max-sixty — this one needs your call, because the answer turns on intent rather than on the code: does worktrunk claim <fish config dir>/conf.d/{cmd}.fish by name wherever fish reads it, or only where worktrunk wrote it? Uninstall's own directory scan already takes the safe form, gating on is_worktrunk_managed_content; install's cleanup does not.
I have deliberately not pushed fixes for any of this. The uninstall fix means widening which directories wt config shell uninstall deletes from, which is the same surface, and self-authorizing that is what the hold exists to prevent.
Windows resolves to %APPDATA%, not fish's config directory
Inline below. choose_base_strategy() is not the XDG strategy everywhere, and no test can catch the difference because set_temp_home_env pins APPDATA to $HOME/.config.
check-docs is red on an unrelated WebKit flake — page.goto: WebKit encountered an internal error navigating to /remove/, a page this PR doesn't touch, in desktop code examples fit the content column. Recent main runs are green, so a rerun should clear it.
… conf.d pinned Self-review findings on the first commit: - Uninstall and `wt config show` still built fish's directories by hand, so under a custom $XDG_CONFIG_HOME install wrote where fish reads and uninstall scanned where it doesn't. Both now use the same resolver. - Routing legacy_fish_conf_d_path through it moved install's unread whole-file deletion onto a conf.d worktrunk never wrote. Reverted to the hardcoded path, with a note on why it isn't one of the delegated paths. - choose_base_strategy resolves %APPDATA% on Windows, which fish has no notion of; use etcetera's Xdg strategy, identical elsewhere. The regression test now covers uninstall as well as install.
…ll wrote A custom $XDG_CONFIG_HOME means an older worktrunk put the wrapper and completion under ~/.config/fish, where fish never read them. Uninstall now scans both that directory and fish's real one, so those files are still removed; the scans are gated on worktrunk-managed content, so the wider search reaches only files worktrunk wrote.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Self-review of the two commits since the last pass. All three threads from that review are addressed, and I'm resolving them. Two new findings below, plus one cleanup note.
fast-checks is red on the new docstring, not on a flake
The doc step of wt hook pre-merge --yes lockfile doctest doc fails with exit 101. Reproduced locally at this head with RUSTDOCFLAGS='-Dwarnings' cargo doc --no-deps --document-private-items:
warning: public documentation for `fish_config_dir` links to private item `config_paths`
--> src/shell/paths.rs:223:8
= note: this link resolves only because you passed `--document-private-items`, but will break without
= note: `#[warn(rustdoc::private_intra_doc_links)]` on by default
The same fires for completion_path and legacy_fish_conf_d_path. fish_config_dir is pub and re-exported from src/shell/mod.rs, while all three link targets are pub(super), so -Dwarnings turns the three into the job's failure. I'm pushing the fix after this review: plain code spans for the three private names, the Xdg link kept.
Windows: the file this PR moves is left where uninstall can't reach it
The move itself is right and the last review asked for it. What's missing is the cleanup on the other side of it.
Before this PR, completion_path's fish arm resolved through choose_base_strategy(). etcetera 0.11 selects that as Windows on Windows (create_strategies!(Windows, Windows) in base_strategy.rs), and Windows::config_dir() forwards to data_dir(), i.e. %APPDATA%. So a released wt config shell install fish on Windows wrote %APPDATA%\fish\completions\wt.fish. After this PR the completion goes to the Xdg config dir instead — %USERPROFILE%\.config\fish\completions absent $XDG_CONFIG_HOME.
scan_for_uninstall's new stranded-directory guard doesn't reach the file left behind. Its stranded completions directory is home.join(".config").join("fish").join("completions"), which on Windows is the new canonical directory, so stranded_completions_dir != completions_dir is false and nothing ever scans %APPDATA%. That reproduces, one platform over, exactly the shape this PR exists to close: wt config shell uninstall fish reports success while a worktrunk-written file stays on disk with no command that can remove it. The PR description sells the Windows move as "correcting a pre-existing miss", so the orphan it creates belongs in the same paragraph either way.
Two defensible answers: add choose_base_strategy()'s config dir as one more content-gated entry in the completions scan (gated on COMPLETION_MARKER, like the two already there), or say in the fish_config_dir docstring that the Windows move strands the old file deliberately and why that's acceptable.
I'm not pushing either, and this is the part that needs your call rather than mine, @max-sixty. Widening which directories wt config shell uninstall deletes from is the surface references/review-pr.md holds for a human — command wt config shell uninstall fish, file src/commands/configure_shell.rs (scan_for_uninstall) — and the widening already in this diff, the ~/.config/fish scan, sits on the same hold. They're one decision, not two. Install's deletion surface is unchanged by this PR, as the description says.
~/.config/fish is now written out in five places
The directory the PR exists to stop hardcoding is hardcoded in five sites across three files: legacy_fish_conf_d_path in src/shell/paths.rs, the conf.d entry in scan_for_detection_details, and the stranded-functions, conf.d and stranded-completions directories in scan_for_uninstall. Each carries its own comment re-explaining that this is where worktrunk wrote before it resolved $XDG_CONFIG_HOME.
A legacy_fish_config_dir(home) sitting next to fish_config_dir would hold that rationale once and make the pair of directories every one of these sites reasons about explicit in its signature — which is the same consolidation the PR already argues for on the other half. Not blocking, and it can wait for the decision above, since that decision may add a third directory to the set.
Each scan repeated the extension and predicate, which rustfmt then broke across lines so the trailing `?` sat alone on a line only the error path reaches. One closure per group reads better and puts each call back on a single line.
| // `$XDG_CONFIG_HOME` — scanned as well so a wrapper stranded | ||
| // by an older install is still removed, and skipped entirely | ||
| // when they're the same directory. Every scan is gated on |
There was a problem hiding this comment.
we don't want this sort of complexity in our code. if someone moves the config dir, then we'll miss the uninstall, that's fine. It's not an active config dir anyway at that point.
The broader goal was to simplify as much as possible!
There was a problem hiding this comment.
Done in c6fbe50ef — uninstall now scans only the directory install writes to. The paired stranded directory, its inequality guard and the scan closure the pair needed are all gone, from both the wrapper block and the completion block; the test drops the planted stranded wrapper with them. What's left of this PR in scan_for_uninstall is one line: functions_dir comes from the resolver instead of a hardcode.
Same answer applies to the %APPDATA%\fish\completions file the Windows half of this move leaves behind, which I'd raised in the review — fish doesn't read it either, so it isn't chased. Noted in the PR description rather than coded around.
The entry claimed an unset or default $XDG_CONFIG_HOME is unaffected. That holds on Unix, where choose_base_strategy() already was the XDG strategy, but not on Windows: etcetera selects the Windows strategy there and its config_dir() forwards to data_dir(), so the completion used to land in %APPDATA%\fish\completions and now follows the wrapper.
Per review: a wrapper or completion an older worktrunk left under `~/.config/fish` while $XDG_CONFIG_HOME pointed elsewhere is not in a directory fish loads, so uninstall missing it costs nothing. Scan only the directory install writes to, which drops the paired stranded directory, its equality guard and the scan closure the pair needed.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Self-review of the four commits since the last pass. scan_for_uninstall is back to one directory per file kind, which is what the review above asked for. One finding left, and it lands on my own earlier suggestion.
Xdg doesn't resolve the $HOME the Windows rationale rests on
fish_config_dir's docstring justifies Xdg over choose_base_strategy with "where it runs on Windows at all it is under an environment that supplies a POSIX $HOME". Xdg::new never consults that variable on Windows: it takes its home from etcetera::home_dir → std::env::home_dir, which returns %USERPROFILE% there and documents that it stopped reading HOME on Windows in Rust 1.85 specifically so a Cygwin or MSYS /home/you wouldn't leak in.
So in the environment that sentence names, the helper resolves %USERPROFILE%\.config\fish — a directory that fish reads no more than %APPDATA%\fish did. I'm not proposing a code change: one resolver with no platform branch is the simpler code, and it lands the completion where the wrapper already resolved. What's wrong is the reason given for it, here and in the description's "correcting a pre-existing miss" — as written it claims a reachability the move doesn't deliver, and it's the sentence a later reader would use to decide whether the stranded %APPDATA%\fish\completions\wt.fish matters.
Inline suggestion below; I'm pushing it after this review, along with the matching paragraph in the description.
Unix is untouched either way — choose_base_strategy is Xdg on Linux and macOS (create_strategies!(Apple, Xdg) and (Xdg, Xdg) in etcetera's base_strategy.rs).
The rationale for preferring `Xdg` over `choose_base_strategy` rested on fish running under an environment that supplies a POSIX `$HOME`, but `Xdg::new` takes its home from `std::env::home_dir`, which returns `%USERPROFILE%` on Windows and stopped reading `HOME` there in Rust 1.85 — so that `$HOME` is the one thing it won't see. The choice still stands on being the simpler code; the docstring now says so instead.
# Conflicts: # CHANGELOG.md
…obable environments (#4137) Four times in the last 24 hours, `max-sixty` asked a bot PR for less code, and each time the ask was the same one in a different costume: stop encoding another tool's rules in `wt`, and stop defending environments that are already broken. Nothing in `CLAUDE.md` said either, so each PR re-learned it in review. The first extends **Code Quality → Use Existing Dependencies**, which already tells you to reach for a dependency before hand-rolling a utility; the second gets its own heading beside it, since defending an environment has nothing to do with dependencies. Both cases the delegation rule came from resolved *into* its exception rather than out of it — #4085 established that zsh has no "where should the config file go" to ask, and #4124 that MiniJinja exposes no binding list without `unstable_machinery`. The guidance names neither: cited as examples, they read as debt still to pay off, and the zsh decision already lives in `zsh_config_dir`'s docstring, which is where the rule says that reasoning belongs. The generalisation is the maintainer's, not an inference from the diffs — on #4085: *"can we try to remove as much as possible from our code that attempts to interpret the internals of other libraries?"*, prefaced with *"we hit this on some of the sibling issues"*. #4106 is the standing backlog that same instinct produced. **Second half, the anxiety one.** On #4104: *"this is totally fine; we're an order of magnitude too anxious here. if someone doesn't have a resolvable home dir, then honoring the xdg config in worktrunk is the least of their problems"* — the wording here is close to his deliberately. The earlier instance is #4107, where a bot self-review invented a scan of a stranded fish config directory and he cut it: *"if someone moves the config dir, then we'll miss the uninstall, that's fine"*. The **Data Safety** carve-out is explicit because that section rules the opposite way on purpose, and this paragraph must not be read as licensing a silent loss. **Why now rather than at the next instance.** The behaviour is stochastic, so it carries a 5-occurrence floor; the window took it to six (#4085, #4104, #4123, #4124 here, plus #4104's `nu-config` round and #4107 recorded on 2026-09-15 in #3980). The bot also has seven PRs open, over the self-initiated budget — this one is filed anyway because the cost class is a wrong outward action, not compute: #4124 shipped a hand-rolled MiniJinja binding scanner whose correctness gap the maintainer had to find himself. <details><summary>The four corrections, and what each one cost</summary> | PR | Correction | Outcome | |----|-----------|---------| | [#4085](#4085) | "can we just ask `zsh` for whether the config file should go?" | Bot showed the `zsh -f -c` probe relocates the rule rather than removing it, deleted the zsh-source docstring, and gave `zsh_config_dir` the absolute-only guard the module already applied to `$XDG_DATA_HOME`. The rule itself stays in `wt`. Merged. | | [#4104](#4104) | "we're an order of magnitude too anxious here" | Taken as a precondition in `c4089e3c`; `read_tea_config`'s two home-directory resolutions collapsed into one candidate list. Merged. | | [#4123](#4123) | "can't we just delegate all toml parsing to serde?" | Bot tested `serde_ignored` in a scratch crate and reported where `#[serde(flatten)]` blinds it, rather than answering from reasoning. Open. | | [#4124](#4124) | "the new binding scanner still misses parenthesized tuple targets that MiniJinja 2.24 accepts" | Fixed in `5fe64767` across `for`/`set`/`with`; deriving bindings from MiniJinja's parse needs `unstable_machinery`. Open. | Only the last is a correctness defect — the other three are complexity the maintainer declined to carry. The bot absorbed all four within hours, so the gap is not in how it responds but in it not knowing beforehand. Evidence for this run is appended to the `review-runs-tracking` issue [#3980](#3980); the prior two occurrences are under `Run 34943713746`. </details> `CLAUDE.md` is hand-edited, not generated, so no mirror regenerates from it and `test_docs_are_in_sync` is unaffected. --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Maximilian Roos <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
worktrunk 0.78.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Hook scripts read renamed context keys**: the JSON piped to every hook drops `worktree`, `repo_root`, `main_worktree`, and `main_worktree_path` in favour of `worktree_path`, `repo_path`, `repo`, and `primary_worktree_path`. Config templates migrate on load, so hooks written with the old names keep working; scripts reading the JSON, `--execute` templates, and `--var` overrides need updating. (Breaking.) ([#4080](max-sixty/worktrunk#4080)) - **`wt config plugins pi` installs for Pi; oh-my-pi moves to `wt config plugins omp`**: `pi install` wrote an oh-my-pi hook, which Pi never loads; Pi users re-run it to get a Pi extension. Existing oh-my-pi hooks keep working, listed as outdated until `wt config plugins omp install`. (Breaking: scripts that run `wt config plugins pi` for oh-my-pi need `omp`.) [Docs](https://worktrunk.dev/claude-code/#oh-my-pi) ([#4135](max-sixty/worktrunk#4135), thanks @ashebanow) - **Interactive prompts no longer open with a blank line**: `wt config shell install`, `wt config plugins claude install`, and the commit-message setup offer in `wt merge` began with one. ([#4059](max-sixty/worktrunk#4059)) - **`wt config show` gives a single `wt config shell install` hint**: an outdated wrapper, a fish wrapper at the deprecated `conf.d` path, and missing fish completions each printed their own hint. The zsh `compinit` snippet is now syntax-highlighted. ([#4059](max-sixty/worktrunk#4059)) - **`wt config update --output <path>` confirms the write**: it now prints `✓ Wrote user config migration @ ~/migrated.toml` where it printed nothing. `--output=-` stays silent. ([#4053](max-sixty/worktrunk#4053)) ### Fixed - **Removal no longer discards untracked files hidden by `status.showUntrackedFiles = no`**: under that setting, a worktree holding only untracked files looked clean, so `wt remove`, `wt merge`, and `wt step prune` removed it without `--force`. Safety checks now always count untracked files, and auto-staging warnings list every file they stage. ([#4111](max-sixty/worktrunk#4111), thanks @Duang777) - **`wt remove` and `wt merge` check the right worktree under an inherited `GIT_DIR`**: run from a `!wt` git alias or a git hook, which pass `GIT_DIR` down, `wt remove` could delete a dirty worktree without `--force`, and `wt merge` could refuse a clean merge. Both now check the worktree they act on. ([#4082](max-sixty/worktrunk#4082), thanks @Duang777) - **`wt merge` no longer deletes a worktree locked with `git worktree lock`**: the merge completes and prints `Worktree preserved (locked)`. Every Worktrunk removal refuses a locked worktree, even with `--force`; run `git worktree unlock <path>` first. ([#4073](max-sixty/worktrunk#4073), thanks @Duang777) - **`wt config update` no longer overwrites a config edited while its prompt is open**: it wrote the pre-prompt snapshot over the newer file and reported success. It now fails with the path and leaves the newer file; re-running previews the current contents. ([#4127](max-sixty/worktrunk#4127), thanks @zach-hammad-vs for reporting) - **`wt step prune` no longer deletes a branch created minutes ago from an older commit**: `--min-age` aged a branch without a worktree by its commit's date, so a new branch off a day-old commit was pruned on the next run. Age now comes from the branch's oldest reflog entry. ([#4077](max-sixty/worktrunk#4077)) - **A comment or blank line above an inline config section no longer breaks the config**: a save or migration that rewrote `commit = { … }` as `[commit]` put that line inside the brackets. `wt switch`, `wt merge`, `wt remove`, and several `wt step` commands then failed with `Failed to load config`; `wt list` warned and ran without the config. Saves also dropped unrecognized keys from inline sections. ([#4120](max-sixty/worktrunk#4120), thanks @zach-hammad-vs for reporting) - **Config saves keep the trailing comment on a value they rewrite**: a save such as answering the commit-generation offer dropped the comment after each value it rewrote, including one after an inline section's closing brace. ([#4138](max-sixty/worktrunk#4138)) - **Ignored project-config keys warn from every worktree**: an unknown key in `.config/wt.toml`, or one that belongs in user config such as `[merge]`, warned only in the main worktree, so `wt merge` from a linked worktree ignored it silently. ([#4145](max-sixty/worktrunk#4145), thanks @ee-prog for reporting) - **`wt merge` skips `post-commit` when it removes that hook's worktree**: before, the hook ran in the primary worktree when the removed one sat inside the repository, and otherwise didn't run. The merge now prints `▲ Skipped post-commit`; move work that must finish there to `pre-remove`. ([#4049](max-sixty/worktrunk#4049)) - **`wt switch` recovers from a removed worktree in a bare repository**: `wt switch` and the picker surfaced git's raw `fatal: Unable to read current working directory` instead, and the removed-directory message lacked `wt switch ^`. ([#4067](max-sixty/worktrunk#4067)) - **`wt config shell install fish` puts the wrapper where fish reads it under a custom `$XDG_CONFIG_HOME`**: the wrapper always went to `~/.config/fish/functions/`, so install reported success while `wt switch` changed no directory. On Windows, the fish completion moves from `%APPDATA%\fish\completions` to the wrapper's directory. ([#4107](max-sixty/worktrunk#4107)) - **`wt config shell install zsh` honours `$ZDOTDIR` only when it is absolute**: an empty or relative value resolved against the current directory, so install appended to a `.zshrc` under the current directory and reported success while the file zsh reads went untouched. A non-absolute value now falls back to `$HOME`. ([#4085](max-sixty/worktrunk#4085)) - **`wt config shell install` for Nushell no longer deletes a `wt.nu` under the current directory**: an empty or relative `$XDG_CONFIG_HOME` resolved against it, so install removed a `nushell/vendor/autoload/wt.nu` beneath it unread, as a stale wrapper. It now falls back to `~/.config`, which also fixes unread `tea` logins that let `wt switch pr:<n>` treat a Gitea host as GitHub. ([#4104](max-sixty/worktrunk#4104)) - **`wt switch --create` names the branch a failed worktree add leaves behind**: `git worktree add -b` writes the branch ref before populating the worktree, so a failure in between left the branch with no worktree, and the next attempt reported a name collision. The error now says how to delete or reuse it. ([#4109](max-sixty/worktrunk#4109), thanks @technicalpickles for reporting) - **`wt config shell install` no longer tells an already-wrapped shell to restart**: reinstalling from a shell with the wrapper loaded, such as after a version bump, printed `↳ Restart shell to activate shell integration`. ([#4059](max-sixty/worktrunk#4059)) - **`wt config shell install` migrates a deprecated `conf.d` fish wrapper when `~/.config/fish/functions` is missing**: before, only `wt config shell install fish` migrated it. `wt config show` now reports that wrapper even when fish isn't on `PATH`. ([#4059](max-sixty/worktrunk#4059)) - **Plugin status and uninstall checks ask the agent CLIs**: `wt config show` could list an installed Claude Code plugin or Gemini CLI extension as not installed, and `wt config plugins claude|codex uninstall` could report success over a marketplace still configured. A repeat Claude uninstall now runs both removals instead of stopping at `Plugin not installed`. ([#4048](max-sixty/worktrunk#4048), [#4054](max-sixty/worktrunk#4054)) - **`wt config plugins opencode install` no longer writes the plugin into the current directory**: with `OPENCODE_CONFIG_DIR` set but empty, it wrote `plugins/worktrunk.ts` there, typically inside a repository, reporting success though OpenCode never saw it. An empty value now counts as unset. ([#4084](max-sixty/worktrunk#4084)) - **The OpenCode plugin clears its activity marker when OpenCode 1 disposes it**: only explicit session deletion cleared it, so a finished session kept its `💬` and `wt list` showed it as active until `wt config state marker clear` was run by hand. ([#4129](max-sixty/worktrunk#4129), thanks @drewdas for reporting) - **`wt config update` migrates `[ci] platform` into a `[forge]` section that only sets `hostname`**: that config, common with GitHub Enterprise and self-hosted GitLab, kept the deprecated key with no deprecation warning. ([#4061](max-sixty/worktrunk#4061)) - **Deprecated keys in an inline `[projects]` entry now migrate**: `"example.com/org/repo" = { merge = { no-ff = true } }` skipped the migration the section form got, so the per-project setting was ignored. ([#4122](max-sixty/worktrunk#4122), thanks @zach-hammad-vs for reporting) - **A deprecated config section the migration can't rewrite now warns**: `select = "not a table"`, or a `[select]` whose `[switch.picker]` destination is already set, was ignored without a message. It now reports `unknown field select (will be ignored)`. ([#4121](max-sixty/worktrunk#4121), thanks @zach-hammad-vs for reporting) - **`wt config update` no longer changes what a template renders**: it could rename `{{ repo_root }}` inside a quoted s See merge request: Harmonybrew/homebrew-core!20435
Problem
config_paths's fish arm resolved the wrapper directory as a hardcoded~/.config/fish, whilecompletion_path's fish arm two functions down used the XDG config directory. Same tool, same process, two rules — so a$XDG_CONFIG_HOMEpointing anywhere but~/.configsent the two files to different directories. Fish reads$__fish_config_dir, which follows$XDG_CONFIG_HOME: it autoloaded the completion and never saw the wrapper.Nothing surfaced the split.
wt config shell install fishprinted✓for both files, andwt config showread its "configured" answer back from the same hardcoded path it had just written, so the report agreed. What the user saw waswt switchleaving the shell in the same directory, with completions working.Solution
One
fish_config_dir()helper resolves fish's config directory, and every path fish itself reads goes through it: the wrapper (config_paths), the completion (completion_path), the directorieswt config shell uninstallscans, and thefunctions/entry inscan_for_detection_detailsthatwt config showreports from. Install, uninstall and detection agree on one directory rather than three hardcodes and one lookup.The helper uses
etcetera'sXdgstrategy rather thanchoose_base_strategy, which resolves%APPDATA%on Windows — fish has no%APPDATA%notion on any platform, and one resolver with no platform branch is the simpler code. On Unix the two are identical, so this is a no-op there. On Windows it moves the fish completion off%APPDATA%\fish\completionsonto%USERPROFILE%\.config\fish\completions, where the wrapper already resolved — that is the two files agreeing, not a path fish can load:Xdg::newtakes its home fromstd::env::home_dir, which returns%USERPROFILE%on Windows and stopped readingHOMEthere in Rust 1.85, so the POSIX$HOMEa Cygwin or MSYS fish runs under is the one thing it won't see. The%APPDATA%completion an earlier install wrote is left in place, like the other pre-fix files.Uninstall does not chase the
~/.config/fishdirectories a pre-fix install wrote to. Fish never loaded those files, so they are not integration to remove, and scanning a second directory per file kind costs more machinery than the case is worth. The same applies to the Windows completion this moves off%APPDATA%.Two things deliberately stay pinned to
~/.config/fish:legacy_fish_conf_d_path, which names a file worktrunk wrote rather than one fish reads. Install removes what it resolves to whole and unread, so resolving it through$XDG_CONFIG_HOMEwould both stop finding the stranded file and start deleting aconf.d/{cmd}.fishin the directory fish actually loads — one worktrunk never wrote. Install's deletion surface is therefore unchanged by this PR.scan_for_detection_details'sconf.dentry, becauseconfig/show.rsdecideslegacy_fish_has_integrationby comparing that result's path againstlegacy_fish_conf_d_path. Resolving the two by different rules would stop the "deprecated location" row from ever firing.Testing
test_configure_shell_fish_honors_xdg_config_homeinstalls with$XDG_CONFIG_HOMEpointed at a directory other than$HOME/.config, asserts the wrapper and the completion both land under it, then uninstalls and asserts both are gone.It fails on
3a6d9c623853befa4ac077442d3d26702d2b9411with the wrapper missing, and fails again on the uninstall assertion if only the install side is fixed — verified by reverting the uninstall hunk.The existing fish tests did not catch any of this because
set_temp_home_envpinsXDG_CONFIG_HOMEto$HOME/.config— the one value that makes the hardcode and the XDG lookup agree. Nothing can catch the Windows difference for the same reason: that helper pinsAPPDATAto$HOME/.configtoo.cargo test --test integration configure_shell(63),config_show(196) andshell(101) pass locally, as doescargo clippy --all-targets.Scope
This is item 3 of the survey in #4106, which asks not to be turned into a single PR. The other items are independent and untouched here. #4104 edits
src/shell/paths.rstoo (the Nushell paths and theXDG_*_HOMEguards) without overlapping these hunks. The survey's fuller remedy for this item — asking fish itself viafish -c 'echo $__fish_config_dir', thenu_dirs()shape — is still open and isn't verifiable from CI without fish installed.Refs #4106 — automated triage