Repository navigation
fix(shell): honour $ZDOTDIR only when it is an absolute path - #4085
Conversation
An exported-but-empty ZDOTDIR resolved zsh's config to the relative `.zshrc`, so `wt config shell install` appended the integration line to a .zshrc in the invocation directory and uninstall rewrote that file instead of the user's. zsh itself falls back to $HOME when ZDOTDIR is unset or empty. legacy_nushell_autoload_dirs gets the matching absolute-only guard its XDG_DATA_HOME sibling already has.
worktrunk-bot
left a comment
There was a problem hiding this comment.
zsh doesn't read an empty ZDOTDIR as $HOME — it reads it as /. sourcehome() null-checks the parameter instead of testing it for emptiness, so an exported-but-empty value sends zsh to /.zshrc. Verified against zsh 5.9 (ubuntu-24.04), with a marker-exporting .zshrc in both $HOME and the cwd:
$ ZDOTDIR= HOME=$D/home strace -e trace=openat zsh -i -c 'echo MARKER=$MARKER'
openat(AT_FDCWD, "/.zshenv", O_RDONLY|O_NOCTTY) = -1 ENOENT
openat(AT_FDCWD, "/.zshrc", O_RDONLY|O_NOCTTY) = -1 ENOENT
MARKER=
$HOME is still the right target for worktrunk to pick — /.zshrc is a file nobody has, and either beats writing into the invocation directory. But "this is zsh's own rule" is the justification the change rests on, and it's asserted in three places: the zdotdir_or_home docstring, the changelog entry, and the new test's docstring. Suggestions inline.
It also narrows what the PR fixes, which the changelog and PR body should reflect. The stray write is fixed; the silent non-activation is not. With ZDOTDIR="" still exported, the line now lands in a file zsh doesn't source either, and wt config show reads back from that same file — so it still reports integration as installed while nothing runs, which is the symptom the PR opens with, one file over. Whether install should say anything when ZDOTDIR is set but empty is a user-output decision worth making explicitly rather than leaving implied.
Separately: a non-empty but relative ZDOTDIR still resolves against wt's cwd. ZDOTDIR=dotfiles appends to <cwd>/dotfiles/.zshrc, creates it when absent, and hands uninstall that path to rewrite whole — the same consequence this PR is closing, one env value over. zsh resolves a relative value against zsh's own startup directory, which wt can't know at install time; the XDG_CONFIG_HOME hunk in this PR took the absolute-only route for that reason, and the same argument reaches zdotdir_or_home.
zsh null-checks ZDOTDIR rather than testing it for emptiness, so an exported-but-empty value sends zsh to /.zshrc — verified with strace on zsh 5.9. Falling back to $HOME is worktrunk's own choice (the useful target, and the file wt config show reads back from), not zsh's rule. Correct the claim in the zdotdir_or_home docstring, the changelog entry, and the regression test's docstring; the resolution itself is unchanged.
# Conflicts: # CHANGELOG.md
The new doc comment and the changelog entry pointed at legacy_nushell_autoload_dirs as already applying the absolute-only rule to XDG_CONFIG_HOME. It doesn't — that guard is added by #4085, which is still open, so the claim held only if that PR merged first. nushell_data_dir_fallback in the same file applies the rule to XDG_DATA_HOME today, independent of merge order; cite that instead.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # src/shell/detection.rs # src/shell/paths.rs # tests/integration_tests/configure_shell.rs
|
We hit this on some of the sibling issues — can we try to remove as much as possible from our code that attempts to interpret the internals of other libraries? Do we need to know about this env var, or can we just ask |
Replaces the empty-string special case with the absolute-only guard this module already applies to $XDG_DATA_HOME and (via etcetera's Xdg) $XDG_CONFIG_HOME, so zsh stops being the one external config variable read without it. One helper, `absolute_env_dir`, now answers for all three. Drops worktrunk's reading of zsh's empty-value behaviour from the docs and covers the relative case (`ZDOTDIR=dotfiles`), which resolved against wt's invocation directory exactly as the empty value did.
|
Agreed, and the interpretation is gone — but asking zsh isn't what removes it, because zsh has no "where should the config file go" to ask. Pushed the smaller change instead: On the probe specifically: the nearest thing to asking is Same guard also closes the relative case I flagged in review and this PR didn't fix: Still open, unchanged by this: with zsh 5.9 behaviour these choices rest onA marker-exporting Empty sources neither file — zsh reads |
# Conflicts: # CHANGELOG.md
worktrunk-bot
left a comment
There was a problem hiding this comment.
Three changes, all of which I'm pushing to this branch.
The XDG_* hunks in src/shell/paths.rs collide with #4104. That PR rewrites nushell_data_dir_fallback and legacy_nushell_autoload_dirs — the same two functions this one routes through the new absolute_env_dir — to call etcetera::base_strategy::Xdg::config_dir(), and its body already states that it supersedes this PR's shell/paths.rs hunk. The two now edit the same lines with two different mechanisms, so whichever lands second silently decides which one survives. It also cuts against the direction on this thread: a hand-rolled is_absolute() filter newly applied to $XDG_CONFIG_HOME is exactly the interpretation #4104 is deleting, at your request there. $ZDOTDIR is the one variable with no etcetera equivalent, so it stays here; narrowing to it inlines the check into zsh_config_dir, drops absolute_env_dir, and leaves the two PRs with no overlapping hunks at all.
Nothing pins that an absolute $ZDOTDIR is still honoured. Every existing zsh test sets ZDOTDIR to $HOME itself or to /dev/null for shell isolation, and the new test only covers the values that are now ignored. Replacing zsh_config_dir's body with home.to_path_buf() — dropping $ZDOTDIR support outright — passes all 65 configure_shell tests and all 196 config_show tests. The guard this PR adds and removing the feature are indistinguishable to the suite, so the test case for the honoured value is the one that makes the rest of them mean something.
The base merge left two changelog entries unseparated. Resolving the CHANGELOG.md conflict in 50c497d put the zsh entry and the wt config update entry on adjacent lines; every other entry in ### Fixed has a blank line before it.
The shared `absolute_env_dir` helper also rewrote the two `XDG_*` reads in this module, which #4104 replaces with `etcetera::base_strategy::Xdg` — the same lines, a different mechanism, and whichever landed second would have decided silently. Those two reads go back to their form on main, the check inlines into `zsh_config_dir`, and the two PRs no longer share a hunk. Adds the absolute-`$ZDOTDIR` case the suite was missing: every other zsh test points the variable at `$HOME` or `/dev/null`, so ignoring it outright passed all 261 shell tests.
worktrunk-bot
left a comment
There was a problem hiding this comment.
zsh_config_dir's docstring ends with "so zsh stops being the one variable read without it" — the one claim in this PR a reader would grep the module to check, and it doesn't hold. legacy_nushell_autoload_dirs, in the same file, still reads $XDG_CONFIG_HOME at face value (if let Ok(xdg_config) = std::env::var("XDG_CONFIG_HOME") … PathBuf::from(xdg_config).join("nushell")): that is the read the earlier revision guarded and this one handed back to #4104 so the two PRs share no hunk. Narrowing the scope to $ZDOTDIR was right; the sentence didn't narrow with it, and as written it asserts a module-wide invariant that only becomes true if another open PR merges.
Dropping the clause leaves the docstring accurate in either merge order, which is what I'm pushing — here and in the same sentence in the PR body.
legacy_nushell_autoload_dirs still reads $XDG_CONFIG_HOME at face value; #4104 brings that one under etcetera's Xdg, so the exclusivity claim was true only for a revision this PR no longer carries.
Drop this PR's CHANGELOG.md entry. Changelog entries are written from the commits at release time (CLAUDE.md, Releases), so an open PR carrying an entry drops it rather than resolving a conflict on it.
…ectory read (#4104) `wt`'s Gitea support reads `tea`'s config file directly to answer "is tea logged in to this host?" — `is_authed_for` for the `wt switch pr:<n>` forge dispatcher, `has_any_login` for the CI-status backend. `read_tea_config` took `$XDG_CONFIG_HOME` at face value, so an exported-but-empty value turned the lookup into the relative `tea/config.yml`, resolved against whatever directory `wt` was invoked from. The user's real `~/.config/tea/config.yml` was never read, and where the repository happened to contain a `tea/config.yml`, that file was consulted instead. With no logins found, both callers report no Gitea login, and the effect is silent: - `wt list --full` in a Gitea repository drops the CI column (`ci_status/mod.rs` gates the backend on `has_any_login()`). - `wt switch pr:<n>` against a self-hosted host that `tea` is logged in to falls through to the GitHub CLI (`switch.rs`, the forge dispatcher). The [XDG base directory spec](https://specifications.freedesktop.org/basedir-spec/latest/) makes both exclusions: an unset *or empty* value means the `$HOME`-relative default, and a relative path is invalid and must be ignored. ## Why this isn't gitea-specific It isn't, and the first revision was wrong to scope it there. worktrunk read an `XDG_*_HOME` variable at four sites, each joining a subpath onto it, and each had written the rule at a different strictness — so `XDG_CONFIG_HOME=cfg` picked the target by cwd at three of them. The three that mean "the XDG config directory" now delegate to `etcetera::base_strategy::Xdg::config_dir()` — the env read, the spec's absolute-only filter, and the `~/.config` fallback in one call, from the crate worktrunk already resolves its own config with. Each caller's hand-written `~/.config` fallback goes with it, so the fix is net −39 lines. | Site | Variable | Before | After | |---|---|---|---| | `read_tea_config` (`git::remote_ref::gitea`) | `XDG_CONFIG_HOME` | face value | `Xdg::config_dir()` | | `opencode_plugins_dir` (`commands::config::opencode`) | `XDG_CONFIG_HOME` | empty filtered, relative not | `Xdg::config_dir()` | | `legacy_nushell_autoload_dirs` (`shell::paths`) | `XDG_CONFIG_HOME` | face value | `Xdg::config_dir()` | | `nushell_data_dir_fallback` (`shell::paths`) | `XDG_DATA_HOME` | absolute-only, written inline | unchanged | `Xdg` rather than `choose_base_strategy()` at the first three: both tools honor `$XDG_CONFIG_HOME` on every platform, which `Xdg` keeps and the native strategies don't. Their *defaults* differ — OpenCode reads `~/.config` everywhere (`~/Library/Application Support/opencode/` is its managed-settings path, which is why `opencode_plugins_dir` already avoided `dirs::config_dir()`), while tea's default comes from `github.com/adrg/xdg`: `~/Library/Application Support` on macOS, `%LOCALAPPDATA%` on Windows. So `Xdg` matches tea's default on Linux only; `choose_base_strategy()` would give `~/Library/Preferences` and `%APPDATA%`, matching it on neither. worktrunk's own config keeps `choose_base_strategy()`, which is the right answer for a native CLI config dir. That leaves a pre-existing gap this PR doesn't close: on macOS with `$XDG_CONFIG_HOME` unset, `wt` looks in `~/.config/tea/config.yml` while tea's logins are in `~/Library/Application Support/tea/config.yml` — the same silent symptom described above. It is unchanged from `main`, and whether `read_tea_config` should also try tea's native macOS and Windows defaults is a behavior change past this PR's scope. Beyond tea, this fixes two real targets: `wt config plugins opencode install` with a relative `$XDG_CONFIG_HOME` wrote the plugin under the invocation directory (the empty case was fixed in #4084; the relative case was not), and the Nushell uninstall's search for wrappers stranded by older versions searched a relative `nushell/vendor/autoload`. ## The home directory is a precondition `etcetera`'s `Xdg` captures the home directory at construction, so `Xdg::new()` fails when none can be resolved even where `$XDG_CONFIG_HOME` is set and absolute — a container run under a uid with no passwd entry and no `$HOME`. Per review, that is accepted rather than worked around: a machine with no resolvable home has larger problems than worktrunk's XDG reads, and preserving the case means reading the variable by hand ahead of etcetera at every site, which is the duplication this PR deletes. Taking it as a precondition simplifies one more site than the delegation itself did. `read_tea_config` resolved a home directory twice — inside `Xdg::new()` for `~/.config/tea/config.yml`, then again through `path::home_dir()` for the legacy `~/.tea/tea.yml`. Both now come off the one strategy (`xdg.home_dir()`), and the two `if let` chains collapse into one candidate list. The no-home case read neither file before, so nothing changes behaviorally. ## The fourth site stays spelled out `nushell_data_dir_fallback` is the one read that doesn't follow the XDG spec — it mirrors Nushell's own `resolve_xdg_base` (`XDG_DATA_HOME` when absolute, otherwise `dirs::data_dir()`), because etcetera's `Xdg::data_dir()` falls back to `~/.local/share` everywhere, which is the wrong directory on macOS and Windows, while the `Apple`/`Windows` strategies that get those right ignore `XDG_DATA_HOME`. It already applied the absolute-only rule, so it is unchanged here apart from moving to `var_os` for parity with the other sites. An intermediate revision delegated it to [`nu-config`](https://crates.io/crates/nu-config), Nushell's own path-resolution crate, and that was dropped in `a1fe07cb8` after measuring it. The delegation bought drift-proofing, not coverage: `resolve_paths(...).vendor_autoload_dirs.last()` resolves to the same directory the ~15 hand-written lines compute on all three platforms, because nu-config appends the `$XDG_DATA_DIRS` and macOS `/Library/Application Support` entries *before* the data-home one and only the last entry is the write target. Against that it cost eight new `Cargo.lock` entries and ~18.7k lines of source — over half of it the `darling` chain, pulled in for one `#[derive(Setters)]` on nu-config's always-compiled `TestEnv` — and a version lock to a Nushell release, so it would answer for the pinned version rather than the installed one in exactly the case where there is no installed `nu` to check against. Worktrunk already delegates the reachable half: `nu_dirs()` asks a running `nu` for `$nu.vendor-autoload-dirs | last`, and that is what the install writes to whenever `nu` is on PATH. The reinstated lines answer only the case shelling out can't reach — the uninstall scan looking for a wrapper an older worktrunk stranded on a machine where Nushell has since been removed. ## Testing The OpenCode install target — the one site where a bad value writes a file rather than failing to read one — is pinned end-to-end by `test_opencode_install_ignores_relative_xdg_config_home` in `tests/integration_tests/config_show.rs`. Those tests spawn `wt` as a child process, so `cmd.env("XDG_CONFIG_HOME", …)` sets the child's environment and races nothing; it is a sibling of `test_opencode_install_treats_empty_config_dir_as_unset`, which #4084 added for the same shape one rung up the precedence. It fails against the pre-fix resolution and passes now. `test_uninstall_nushell_finds_wrapper_under_xdg_data_home` covers the `$XDG_DATA_HOME` candidate end-to-end. The XDG *config* rule itself is not unit-tested here: etcetera's XDG strategy carries doctests asserting exactly the empty-and-relative behavior, so a local copy would be restating a dependency's contract. ## Overlap with #4085 That PR adds an absolute-only filter inline to `legacy_nushell_autoload_dirs`. This supersedes that hunk — its `ZDOTDIR` change is independent and unaffected, so on rebase #4085 should drop the `shell/paths.rs` hunk and the CHANGELOG sentence about it. --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: worktrunk-bot <[email protected]>
The delegation rule cited #4085 and #4124 as failures to ask the library, but both evaluated delegation and kept the re-derived rule: zsh has no "where should the config file go" to ask, and MiniJinja exposes no binding list without unstable_machinery. As written an agent would read zsh_config_dir's absolute-only guard - which keeps the whole-file uninstall rewrite out of the invocation directory - as outstanding debt. Also gives "don't defend improbable environments" its own heading, since it has nothing to do with using existing dependencies, and pins that dropping a fallback still means returning an error rather than .expect().
…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
wt config shell install zshappends the integration line to a.zshrcin whatever directorywtwas run from wheneverZDOTDIRis exported with a value that isn't an absolute path — empty, or a baredotfiles. A dotfiles checkout is the obvious way to have such a file, and it's also a likely place to run the installer from. The file zsh reads goes untouched, so integration silently never activates;wt config showreports from the same wrong file, so it agrees that everything is installed. Where no.zshrcexists in the invocation directory, install creates one there.line_based_config_pathsresolved zsh's config asZDOTDIRor$HOME, but readZDOTDIRwith.map(PathBuf::from).unwrap_or_else(|_| home)— an empty value isOk(""), notErr, so it passed through andPathBuf::from("").join(".zshrc")is the bare relative.zshrc.scan_for_detection_details(whatwt config show's shell section reads from) carried an identical copy.$ZDOTDIRis now honoured only when it holds an absolute path, and both sites go through onezsh_config_dirhelper so they can't drift again. That guard isn't new to the codebase —nushell_data_dir_fallbackalready applies it to$XDG_DATA_HOME, and etcetera'sXdgapplies it to$XDG_CONFIG_HOMEbehindfish_config_dir— and$ZDOTDIRnow goes through it too. Anything non-absolute falls back to$HOME, which is also wherewt config showreads back from, so install and detection agree.The guard covers the relative case for the same reason it covers the empty one: zsh resolves a relative
$ZDOTDIRagainst zsh's own startup directory, whichwthas no way to know at install time. There is no answer to reproduce, only a wrong file to stay out of. A shell started with an unusableZDOTDIRstill won't source the line until the variable is unset or pointed at a real directory; what changes here is thatwtstops editing an arbitrary file in the current directory.This matters more than a stray file because of what these paths feed.
wt config shell installappends to the rc file anduninstall_previewed_linesrewrites it whole — the rc-file write surfaceCLAUDE.md's Data Safety section singles out. A wrong path decides which file gets rewritten.Scope
$ZDOTDIRonly. An earlier revision routed this module's$XDG_DATA_HOMEand$XDG_CONFIG_HOMEreads through a sharedabsolute_env_dirhelper; #4104 replaces those same two reads withetcetera::base_strategy::Xdg, so they are left exactly as they are onmainhere and the two PRs share no hunk.$ZDOTDIRis the one variable with no etcetera equivalent.Testing
test_configure_shell_non_absolute_zdotdir_uses_homeruns the realwt config shell install zsh --yesfrom a scratch directory holding a decoy.zshrc, once withZDOTDIR=""and once withZDOTDIR=dotfiles, then asserts the line landed in$HOME/.zshrcand the decoy is byte-identical. Each case fails against the code it guards.test_configure_shell_absolute_zdotdir_is_honouredis its companion, and the case that makes the other two mean something: every other zsh test in the suite pointsZDOTDIRat$HOMEitself or at/dev/nullfor shell isolation, so azsh_config_dirthat ignored the variable outright passed all 261configure_shellandconfig_showtests. It fails against that mutation.This is the same defect class as #4084 (
OPENCODE_CONFIG_DIR), found while reviewing that change, but a separate surface with its own consequence — hence a separate PR.