Worktrees.json does not work - MacOS

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

worktrees.json setup failed with “Failed to cd to worktree directory”

Steps to Reproduce

Probably not minimal reproducible steps, happens locally with not many logs to go through

On MacOS

  • Setup .cursor/worktrees.json with a configuration in your project
  • Go to cursor IDE, create a worktree chat. Ask it to do anything.
  • Setup is not run. The following logs appear:

[2026-01-12T12:34:26.389Z] [worktree-setup] checking config
{“composerId”:“40447bbe-c749-4d48-8800-849ce6e86289”,“worktreePath”:“/Users/myuser/.cursor/worktrees/myrepo/wws”,“rootWorkspacePath”:“/Users/myuser/Projects/myorg/myrepo”,“worktreeConfigFile”:“file:///Users/myuser/.cursor/worktrees/myrepo/wws/.cursor/worktrees.json”,“rootConfigFile”:“file:///Users/myuser/Projects/myorg/myrepo/.cursor/worktrees.json”,“isTargetWindows”:false}
[2026-01-12T12:34:26.392Z] [worktree-setup] selected setup spec
{“key”:“setup-worktree”,“hasCommands”:true,“hasScript”:false,“configPath”:“file:///Users/myuser/.cursor/worktrees/env0/wws/.cursor/worktrees.json”}
[2026-01-12T12:34:26.407Z] [worktree-setup] started terminal session
{“sessionId”:“308509dd-ab4b-4eeb-9445-59f2f5beab0d”,“worktreePath”:“/Users/myuser/.cursor/worktrees/myrepo/wws”}
[2026-01-12T12:34:26.408Z] [worktree-setup] executing combined UNIX script with per-command logs
{“worktreePath”:“/Users/myuser/.cursor/worktrees/myrepo/wws”,“scriptLength”:617}
[worktree-setup] ERROR: Failed to cd to worktree directory
[2026-01-12T12:34:26.844Z] [worktree-setup] all commands finished
{“durationMs”:451}
[2026-01-12T12:34:26.845Z] [worktree-setup] ended terminal session
{“sessionId”:“308509dd-ab4b-4eeb-9445-59f2f5beab0d”}

Expected Behavior

worktrees.json commands are run, no failures in console

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.3.34 (Universal)
VSCode Version: 1.105.1
Commit: 643ba67cd252e2888e296dd0cf34a0c5d7625b90
Date: 2026-01-10T21:17:10.428Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.0.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report.

From the logs, it looks like the config is being found, but the terminal session can’t cd into the worktree directory. A couple quick questions to help debug:

  1. Can you share the contents of .cursor/worktrees.json?
  2. Does the /Users/myuser/.cursor/worktrees/myrepo/wws directory exist before you start Agent Chat? You can check with ls -la ~/.cursor/worktrees/myrepo/
  3. I also noticed a mismatch in the logs: worktreeConfigFile points to env0/wws, but rootWorkspacePath points to myrepo. Is that expected, or does it look like an anomaly?

Also, try this workaround: if the directory doesn’t exist, create it manually before starting the worktree chat.

1: Content

{
“setup-worktree”: [
“pnpm install --frozen-lockfile”,
“npx husky install”
]
}

2: The directory only exists after starting the new chat in worktree mode. But that is intended behaviour, right? Starting a new chat and writing a prompt is what creates a cursor (and git) worktree. Not sure if there is some race condition here, and somehow the setup is run before the worktree folder is created? That’ll be odd, because the logs state that the worktrees.json file is found inside the cursor worktree folder…

  1. This anomaly is just me failing to replace all instance of “env0” to “myrepo” in the logs in attempt to redact information :sweat_smile:
1 Like

Have the same issue of worktrees.json scripts not running