Skip to content

fix(nix): add lsof to the flake test sandbox for --reap discovery#3406

Closed
worktrunk-bot wants to merge 1 commit into
mainfrom
fix/ci-29066326142
Closed

fix(nix): add lsof to the flake test sandbox for --reap discovery#3406
worktrunk-bot wants to merge 1 commit into
mainfrom
fix/ci-29066326142

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

The nix-flake job in the nightly workflow (failed run) failed on:

---- integration_tests::remove::test_remove_reap_kills_process stdout ----
thread '...test_remove_reap_kills_process' panicked at tests/integration_tests/remove.rs:93:9:
child 59765 never discovered

The test was added with the experimental --reap feature in #3396. It spawns a detached sleep child whose cwd is a worktree, then polls reap::processes_under() until the child appears, asserting against a 5s deadline. processes_under() shells out to lsof -d cwd and, by design, returns an empty list on a spawn failure (best-effort — see src/git/reap.rs). With lsof absent from the Nix sandbox PATH, discovery always returns empty, so the child is never found and the poll times out.

This is a packaging-environment gap, not a code regression:

  • The test passed on all three real OS runners (full-tests linux/macos/windows) and failed only in the Nix sandbox — the class of bug the nix-flake job exists to catch.
  • The worktrunk-tests derivation in flake.nix already enumerates the host tools tests shell out to (git, python3, procps for ps). lsof was the one it missed.
  • nix-flake runs only in the nightly workflow, not on PR CI, which is why feat(remove): add experimental --reap to kill worktree processes #3396 merged without this check gating it.

Solution

Add pkgs.lsof to the worktrunk-tests derivation's nativeBuildInputs, alongside the existing git/python3/procps, and extend the comment to explain what needs it. This is the right level — it fixes the sandbox to provide the tool the test requires, matching the established pattern, rather than skipping the test (which would remove the reap safety-net coverage the nightly nix job is meant to provide).

Testing

Not verifiable in the tend CI sandbox: Nix isn't installed and the runner has no root/passwordless-sudo to install it, so nix flake check couldn't be run here. The change is a one-line dependency addition of a standard nixpkgs package (pkgs.lsof) mirroring the adjacent git/python3/procps entries; /proc is known-available in the sandbox (the existing ps-based pgid test relies on it), so lsof -d cwd will resolve the sandbox's own child cwds.

PR CI does not cover this fixnix-flake lives only in .github/workflows/nightly.yaml. To confirm before/after merge, trigger the nightly manually (workflow_dispatch) or wait for the next cron run.


Automated fix for failed run

The nix-flake nightly job failed on integration_tests::remove::
test_remove_reap_kills_process with "child never discovered". The test
(added with the experimental `--reap` in #3396) spawns a detached child
under a worktree and polls reap::processes_under() until it appears,
failing at a 5s deadline otherwise. processes_under() shells out to
`lsof -d cwd`; on a spawn failure it returns an empty list by design, so
with lsof absent from the sandbox PATH the child is never discovered.

The worktrunk-tests derivation already enumerates the host tools tests
shell out to (git, python3, procps for `ps`); lsof was the missing one.
Add pkgs.lsof alongside them.

The test passed on all three real OS runners (full-tests linux/macos/
windows) and failed only in the Nix sandbox, matching a packaging-
environment gap rather than a code regression — the class of bug the
nix-flake job exists to catch. nix-flake runs only in nightly, not on PR
CI, which is why #3396 merged without it gating.

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot resolve conflicts

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Resolved by closing: this PR is superseded by #3410 (merged 2026-07-10), which landed the identical pkgs.lsof fix to the flake test sandbox — and is a strict superset (it also added flake.nix/flake.lock/nix/** to the nightly trigger paths and pointed the test's discovery-timeout panic at lsof).

The merge conflict here is purely the pkgs.lsof line already existing on main; rebasing leaves only a comment-wording difference in flake.nix, so there's nothing substantive left to merge. Closing as redundant rather than force-pushing a no-op. Reopen if I've missed something.

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