Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
When finishing work in a dedicated git worktree and switching/migrating the agent back to the primary checkout, Cursor fails with:
Cannot migrate: failed to detach worktree HEAD
(Error executing git: spawn /usr/bin/git ENOENT, cwd: /Users/roberto.caracappa/Desktop/Shiva/.worktrees/occ-2-gate, command: “git checkout --detach”)
Important: /usr/bin/git EXISTS and works from Terminal (Apple Git 2.50.1). The cwd in the error is a linked worktree directory that has already been removed. Node child_process.spawn reports ENOENT for a missing cwd even when the git binary is present — so this looks like a stale/deleted worktree path during agent migration, not a missing git install.
This often happens after a worktree-based agent session (e.g. created under .worktrees/ via agent/superpowers workflows). The failure is in Cursor’s migrate/detach flow, not in the third-party skill itself.
Steps to Reproduce
- Open a git repo in Cursor IDE (primary checkout).
- Start an agent session rooted in a linked worktree (e.g. .worktrees/).
- Finish the work and remove/clean up that worktree so the directory no longer exists (git worktree list no longer shows it).
- From that same chat/session, try to migrate/switch the agent back to the primary checkout (the UI that runs git checkout --detach).
Observed: migration fails with spawn /usr/bin/git ENOENT and cwd pointing at the deleted worktree path.
Expected Behavior
If the worktree path no longer exists, Cursor should detect that and fall back to the primary checkout (or show a clear “worktree no longer exists” error) without running git checkout --detach in a deleted cwd. Migration should not fail with a misleading git ENOENT when git itself is installed and working.
Operating System
MacOS
Version Information
Version: 3.26.13
VSCode Version: 1.128.0
Commit: 3bfec373749d3d4a53a151283022d49743ab50b0
Date: 2026-10-20T01:50:17.051Z
For AI issues: which model did you use?
Regardless the model.
Additional Information
- macOS darwin 25; /usr/bin/git present and executable.
- Repo uses linked worktrees under .worktrees/.
- At failure time, cwd …/.worktrees/occ-2-gate did not exist; other worktrees under .worktrees/ still did.
- Workaround: File → Open Folder on the primary repo root and start a fresh chat (do not migrate from a deleted-worktree session).
- Related forum reports: agent migration / move_agent_to_root gaps with git worktrees; ENOENT when cwd is a deleted worktree path.
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor