Skip to content

fix(deps): declare dirs as a Windows-only dependency - #4465

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-4464-dirs-windows-only
Oct 13, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-4464-dirs-windows-only

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

After #4436 removed the dirs::data_dir() fallbacks, the only remaining use of dirs is dirs::document_dir() inside #[cfg(windows)] in src/shell/paths.rs (powershell_profile_paths). The nightly check-unused-dependencies job runs cargo udeps --all-targets on Linux, and in run 38353472092 it reports dirs as unused. This PR moves dirs into a [target.'cfg(windows)'.dependencies] table so Linux and macOS builds no longer pull it in. Cargo.lock is unchanged.

I couldn't run cargo udeps locally because it needs a nightly toolchain. The Windows build in this PR's CI confirms that dirs still resolves where it's used.

The same nightly run had a second, unrelated failure, a race in test_promote_bare_repo_with_worktrees. #4466 fixes it separately.

Refs #4464 — automated triage

#4436 removed the last non-Windows use of dirs (dirs::data_dir), leaving
only dirs::document_dir() under #[cfg(windows)]. The nightly cargo-udeps
job, which runs on Linux, now reports dirs as unused.

Refs #4464
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Oct 13, 2026
max-sixty pushed a commit that referenced this pull request Oct 13, 2026
…s new worktree (#4466)

`test_promote_bare_repo_with_worktrees` failed during setup in nightly
[run
38353472092](https://github.com/max-sixty/worktrunk/actions/runs/38353472092).
Its plain `git worktree add` against the bare fixture died with `fatal:
could not open 'worktrees/worktree/locked' for writing: No such file or
directory`. This is the second occurrence: #3918 recorded the same
failure in August and closed it as a one-off.

The cause is Git's own auto-maintenance. The test's `git push` into the
bare repo makes `receive-pack` start `git maintenance run --auto --quiet
--detach` in that repo, which keeps running after the push returns.
Under Git 2.55, auto-maintenance includes the `worktree-prune` task, and
that task deletes any `worktrees/<name>` directory without a `gitdir`
file. `git worktree add` leaves exactly that state for a moment, between
creating `worktrees/<name>` and writing its `locked` file. If the
detached maintenance scans during that moment, it removes the directory,
and the write fails with ENOENT.

The test now sets `maintenance.auto=false` in the bare repo before
pushing. It has to be repo config: `receive-pack` strips `GIT_CONFIG_*`
from its environment for local transports, so the suite's hermetic env
never reaches it.

<details><summary>What was verified locally (git 2.55.0)</summary>

- A GIT_TRACE2 trace of the push shows `receive-pack` spawning `git
maintenance run --auto --quiet --detach`.
- In a bare repo, `git maintenance run --auto` deletes a hand-made
`worktrees/x` directory that has no `gitdir` file.
- Passing `maintenance.auto=false` through `GIT_CONFIG_COUNT` does not
stop the push's maintenance child. The same setting in the bare repo's
config does: the trace then shows no maintenance child.
- The timing overlap itself did not reproduce. 300 serial runs of the
fixture sequence all passed, so the race needs CI-level load. The fix
removes the deleting process rather than narrowing the window.
- `cargo test --test integration step_promote` passes.

</details>

`git commit` also spawns detached auto-maintenance, but the suite's
hermetic env could turn that off. Every failure seen so far came through
the push path, so this PR leaves the commit path alone.

The other failure in the same run, `dirs` reported unused by udeps, is
fixed separately in #4465.

Refs #4464 — automated triage

Co-authored-by: worktrunk-bot <[email protected]>
@max-sixty
max-sixty merged commit a0822c9 into main Oct 13, 2026
42 of 52 checks passed
@max-sixty
max-sixty deleted the fix/issue-4464-dirs-windows-only branch October 13, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants