Summary
On Windows, git worktree remove --force fails with error: failed to delete '<path>': Filename too long when removing taskplane's deeply nested worker worktrees (typically <repo>/.worktrees/henrylach-<batch-id>/lane-N/). The failure is caused by Windows' default MAX_PATH = 260 limit being exceeded by the worktree's node_modules paths.
After the orch's worktree-removal fails, the worktree is left orphaned on disk (registered as removed in git but the directory persists), consuming disk space and potentially confusing future operations. The orch reports cleanup-incomplete via the post-integration banner but doesn't recover.
A reliable workaround exists (cmd /c "rd /s /q <path>"), which uses a different code path that doesn't hit MAX_PATH the same way.
Reproduction
- On a Windows host with default settings (
core.longpaths = false).
- Run any taskplane batch that performs a
npm install inside the worktree (most non-trivial Node projects).
- Worker completes; orch fast-forwards merge.
- Orch attempts to remove the worktree:
git worktree remove --force C:/dev/<repo>/.worktrees/henrylach-<batch-id>/lane-1
- Fails with:
error: failed to delete 'C:/dev/<repo>/.worktrees/henrylach-<batch-id>/lane-1': Filename too long
Concrete evidence
Production batches 20260506T105850 and 20260506T131717 (both on the same Emailgistics-astro repo, ~700 npm dependencies, deeply nested):
$ git worktree remove --force C:/dev/emailgistics-astro/.worktrees/henrylach-20260506T105850/lane-1
error: failed to delete 'C:/dev/emailgistics-astro/.worktrees/henrylach-20260506T105850/lane-1': Filename too long
Followed by orch_integrate reporting:
⚠️ Cleanup incomplete — residual artifacts found:
(default): 1 non-empty .worktrees/ container(s)
The supervisor recovered with:
$ cmd //c "rd /s /q C:\dev\emailgistics-astro\.worktrees\henrylach-20260506T105850"
(succeeds silently)
The cmd rd /s /q command bypasses MAX_PATH in practice (the cmd shell's deletion code path uses different APIs that handle long paths better than git's libc-style unlink chain).
Why this matters
Every Windows-based taskplane operator hits this on every batch with a large node_modules. Symptoms:
- Orch's post-merge cleanup banner shows
Cleanup incomplete after every batch (operator UX clutter).
- Disk fills with abandoned worktrees over time (until the operator notices and manually cleans).
- Operators eventually learn the
cmd rd /s /q trick or enable Windows long-path support — but neither is documented.
The Emailgistics-astro repo had to do this twice during a single recovery flow (2 dead worktrees from 2 batches). Across many batches, the cumulative friction adds up.
Fix proposals
A. Detect and fall back to cmd rd on Windows
In the orch's worktree-removal code (probably in lane-runner.ts or worktree.ts):
async function removeWorktree(path: string): Promise<void> {
const result = execCheck(`git worktree remove --force "${path}"`);
if (!result.ok && process.platform === 'win32' && /Filename too long/i.test(result.stderr)) {
// Fallback: cmd's rd handles long paths via its own deletion code path.
execCheck(`cmd /c "rd /s /q "${path.replace(/\//g, '\\')}""`);
}
}
This is local to the orch's worktree-cleanup code path; doesn't require any Windows configuration changes by the operator.
B. Document the Windows long-path enablement
Add to the taskplane setup docs (or a new docs/windows.md):
Windows operators: taskplane creates deeply nested worktrees that can exceed Windows' default 260-character path limit. To avoid git worktree remove failures during cleanup, enable long-path support either:
- Globally (recommended): run
git config --system core.longpaths true (administrator)
- Per-repo:
git config core.longpaths true in the project root
Additionally, set the OS-level long-path support via group policy or PowerShell:
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
C. Expose a manual orch_cleanup_worktrees() operator tool
For times when the auto-cleanup misses something (regardless of OS), provide an operator-callable tool that scans .worktrees/ for directories not registered with git worktree list and offers to remove them. Useful belt-and-suspenders even with A/B in place.
Recommendation
Ship A. It's a small, contained code change in the orch's worktree-cleanup path with no operator burden. B is useful documentation regardless. C is a nice-to-have for resilience.
Why this is P3 not higher
This is annoying but not blocking — the orch's cleanup-incomplete banner is informational, the worktrees don't break anything until disk fills, and the cmd rd /s /q workaround is reliable. It's a polish issue more than a correctness issue.
Acceptance criteria
Related
Affected version: taskplane@0.28.4 on Windows. Reproducible on any project with a large node_modules tree.
Summary
On Windows,
git worktree remove --forcefails witherror: failed to delete '<path>': Filename too longwhen removing taskplane's deeply nested worker worktrees (typically<repo>/.worktrees/henrylach-<batch-id>/lane-N/). The failure is caused by Windows' defaultMAX_PATH = 260limit being exceeded by the worktree'snode_modulespaths.After the orch's worktree-removal fails, the worktree is left orphaned on disk (registered as removed in git but the directory persists), consuming disk space and potentially confusing future operations. The orch reports cleanup-incomplete via the post-integration banner but doesn't recover.
A reliable workaround exists (
cmd /c "rd /s /q <path>"), which uses a different code path that doesn't hit MAX_PATH the same way.Reproduction
core.longpaths = false).npm installinside the worktree (most non-trivial Node projects).error: failed to delete 'C:/dev/<repo>/.worktrees/henrylach-<batch-id>/lane-1': Filename too longConcrete evidence
Production batches
20260506T105850and20260506T131717(both on the same Emailgistics-astro repo, ~700 npm dependencies, deeply nested):Followed by
orch_integratereporting:The supervisor recovered with:
The
cmd rd /s /qcommand bypasses MAX_PATH in practice (the cmd shell's deletion code path uses different APIs that handle long paths better than git's libc-styleunlinkchain).Why this matters
Every Windows-based taskplane operator hits this on every batch with a large
node_modules. Symptoms:Cleanup incompleteafter every batch (operator UX clutter).cmd rd /s /qtrick or enable Windows long-path support — but neither is documented.The Emailgistics-astro repo had to do this twice during a single recovery flow (2 dead worktrees from 2 batches). Across many batches, the cumulative friction adds up.
Fix proposals
A. Detect and fall back to
cmd rdon WindowsIn the orch's worktree-removal code (probably in
lane-runner.tsorworktree.ts):This is local to the orch's worktree-cleanup code path; doesn't require any Windows configuration changes by the operator.
B. Document the Windows long-path enablement
Add to the taskplane setup docs (or a new
docs/windows.md):C. Expose a manual
orch_cleanup_worktrees()operator toolFor times when the auto-cleanup misses something (regardless of OS), provide an operator-callable tool that scans
.worktrees/for directories not registered withgit worktree listand offers to remove them. Useful belt-and-suspenders even with A/B in place.Recommendation
Ship A. It's a small, contained code change in the orch's worktree-cleanup path with no operator burden. B is useful documentation regardless. C is a nice-to-have for resilience.
Why this is P3 not higher
This is annoying but not blocking — the orch's cleanup-incomplete banner is informational, the worktrees don't break anything until disk fills, and the
cmd rd /s /qworkaround is reliable. It's a polish issue more than a correctness issue.Acceptance criteria
git worktree removefailures from MAX_PATH automatically retry viacmd rd /s /q.node_moduleslonger than 260 chars; run worktree removal; assert the cleanup succeeds.Related
Affected version:
taskplane@0.28.4on Windows. Reproducible on any project with a largenode_modulestree.