Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
The Shell tool’s working_directory parameter is silently ignored in multi-root workspaces. Commands run in the first workspace root instead of the path passed in, with no error returned. The tool’s output footer even claims the cwd is the path I specified, but a follow-up pwd in a later Shell call reveals the cwd was actually the first workspace root — and files get written to the wrong repo.
Two older forum threads describe the same symptom class:
- How to set current directory? (reported fixed ~Jan 9, 2026)
- File Operations Misrouted to a Directory Other than Specified Context
Neither fix covers the multi-root + explicit working_directory case on Cursor 3.1.17.
Steps to Reproduce
-
Open a single Cursor window with a multi-root workspace containing two git repos, e.g.:
- /Users//projects/repo-a (listed first)
- /Users//projects/repo-b
-
Ask the agent to create a directory tree inside repo-b, e.g.
“create subdir-1/{foo,bar}/.gitkeep in repo-b”. -
The agent calls the Shell tool with:
command: “mkdir -p subdir-1/{foo,bar} && touch subdir-1/{foo,bar}/.gitkeep && ls -la subdir-1/”
working_directory: “/Users//projects/repo-b” -
Shell output footer reads:
Current directory: /Users//projects/repo-b
and thels -la subdir-1/at the end appears to succeed. -
In a later Shell call, run
pwdandls /Users/<me>/projects/repo-b/subdir-1.pwdreturns /Users//projects/repo-a (the FIRST workspace root).lson repo-b returns “No such file or directory”.ls /Users/<me>/projects/repo-a/subdir-1shows the tree — the writes landed in the wrong repo.
Expected Behavior
When working_directory is passed to the Shell tool, the command must execute with that cwd. If the parameter cannot be honored, the tool should return an error and NOT execute — rather than silently running in the first workspace root while still reporting "Current directory: " in the output footer.
The misleading footer is the worst part: it actively tells the agent the command ran where it was asked to, so the agent has no way to detect the mis-routing without an extra verification step.
Operating System
MacOS
Version Information
Cursor version: 3.1.17 (commit fce1e9ab7844f9ea35793da01e634aa7e50bce90, arm64)
OS: macOS 25.4.0 (darwin)
Workspace: multi-root (20 folders added to one window)
For AI issues: which model did you use?
Claude (Sonnet/Opus tier) via built-in Cursor agent mode
Additional Information
Impact: destructive and silent. Writes land in the wrong repo with no indication. For engineers working across multi-root workspaces (common pattern — I had 20 repos open in one window), this is a silent correctness bug with a wide blast radius (misplaced commits, stray files under the wrong .git, accidental secrets-leakage scenarios).
Current workaround I’m using:
- Ignore
working_directoryentirely and prefix every command withcd /abs/path && …in a single command string, OR - Use absolute paths in every mkdir/touch/cp/etc., OR
- Open every Shell call with
pwdas a sanity probe.
Does this stop you from using Cursor
No - Cursor works, but with this issue