Failed to move agent root: Cursor cannot switch worktrees / checkout branches on hosts with older Git or limited Bash environments

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Description:

Cursor is unable to properly switch between workspaces and worktrees, which blocks our experiments from running normally. The failure occurs because Cursor’s git fetch command is aborted by unrelated Bash completion errors, even though Git itself succeeds.

Error Message:

Failed to move agent root: Failed to checkout migrated branch "codex/dune-case-studies":
git fetch origin +refs/heads/codex/dune-case-studies:refs/remotes/origin/codex/dune-case-studies --no-tags --recurse-submodules=no --no-write-fetch-head: Command failed: git fetch origin +refs/heads/codex/dune-case-studies:refs/remotes/origin/codex/dune-case-studies --no-tags --recurse-submodules=no --no-write-fetch-head
/usr/share/bash-completion/bash_completion: line 45: shopt: progcomp: invalid shell option name
/usr/share/bash-completion/bash_completion: line 53: complete: command not found
/usr/share/bash-completion/bash_completion: line 56: complete: command not found
/usr/share/bash-completion/bash_completion: line 59: complete: command not found
/usr/share/bash-completion/bash_completion: line 62: complete: command not found
/usr/share/bash-completion/bash_completion: line 65: complete: command not found
/usr/share/bash-completion/bash_completion: line 68: complete: command not found
...

Root Cause Analysis:

The issue is not caused by the Git version — the host is running Git 2.55.0, which is recent and fully supports worktrees.

The actual cause is a shell environment incompatibility. When Cursor executes the git fetch command, it appears to spawn a shell that sources /usr/share/bash-completion/bash_completion. In that shell, the script fails because:

  • shopt -s progcomp is reported as an invalid shell option
  • The complete builtin is reported as not found

Notably, the host is running GNU Bash 5.0.17(1)-release, which does support both progcomp and complete. This strongly suggests that Cursor is not spawning a full Bash shell — on Ubuntu 20.04, /bin/sh is symlinked to dash by default. dash does not support shopt or complete, yet the bash-completion script is still being sourced. This would fully explain the errors.

These errors are written to the output stream, which causes Cursor to treat the Git command as failed — even though the failure is unrelated to Git itself. As a result, Cursor aborts the workspace/worktree switch.

Questions / Requests:

  1. Can Cursor avoid sourcing bash_completion when running Git commands in non-interactive shells? For example, by using bash --noprofile --norc, or by explicitly setting BASH_ENV to empty.
  2. Can Cursor ensure it spawns a proper, full Bash (/bin/bash) rather than a minimal or POSIX-compliant shell such as dash?
  3. Can Cursor distinguish between actual Git failures and unrelated shell initialization warnings? These Bash completion errors should not block the workflow.
  4. Could Cursor harden its shell invocation to be robust against incomplete or minimal shell environments (e.g., in containers, CI, or minimal server installs)?

Environment:

  • Cursor version: 3.22.7
  • Host Git version: 2.55.0
  • Host Bash version: GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
  • OS: Ubuntu 20.04.6 LTS (Focal Fossa)
  • Kernel: Linux epyc-7t83 7.2.0-coconut-svsm-host-97828317fc1d #1 SMP PREEMPT_DYNAMIC Fri Sep 11 14:04:58 CST 2026 x86_64 GNU/Linux

One last check before posting (optional but recommended):

Run this on the host and include the output — it will confirm whether /bin/sh is dash, which is the most likely culprit:

ls -l /bin/sh

If it shows /bin/sh -> dash, that’s the smoking gun. Adding one line like “/bin/sh is symlinked to dash on this host” will make your report much easier for the Cursor team to act on.

If you’d like, I can also draft a short, polite follow-up reply for when a maintainer responds to your thread.

Steps to Reproduce

Switch worktree and checkout branch on the Cursor Agent.

Operating System

MacOS

Version Information

macOS Tahoe

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @bsmei, thanks for the report and the environment details.

The bash-completion lines are almost certainly not what stops the move. Cursor runs git directly (not through sh/dash), and it only treats the command as failed when git itself exits with an error. Those shopt/complete messages come from a bash started by something git launches (for example the login shell on the SSH side of your origin), and they get mixed into the output. The real git error should be the last line or two of that popup, after the bash-completion lines, and usually starts with fatal:.

Could you run these in the repo on the Ubuntu host and paste the output?

  1. git ls-remote origin refs/heads/codex/dune-case-studies
  2. git fetch origin +refs/heads/codex/dune-case-studies:refs/remotes/origin/codex/dune-case-studies --no-tags --recurse-submodules=no --no-write-fetch-head; echo "exit code: $?"
  3. echo "BASH_ENV=$BASH_ENV"

Also, if you still have it, please share the last few lines of the “Failed to move agent root” message (everything after the complete: command not found lines).

If step 1 prints nothing, the branch only exists locally. The agent’s workspace switch currently needs the branch to be on origin, so git push -u origin codex/dune-case-studies and then retrying should get it through. In the meantime you can also ask the agent to keep working in place with an explicit working directory instead of switching its root.