Failed to apply worktree to current branch in Dev Container

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When using Cursor inside a Dev Container, the “Apply” button for worktree changes fails with the error:

Failed to apply worktree to current branch: Unable to read file ‘vscode-remote://dev-container+{hex-encoded-path}/…’

The error contains a vscode-remote:// URI with a hex-encoded container path, suggesting Cursor is trying to resolve the worktree files via the remote URI scheme rather than the local filesystem.

Root Cause Analysis

When Cursor creates worktrees inside a Dev Container:

  • The main repo is at /app (on the develop branch, for example)
  • Cursor creates worktrees at ~/.cursor/worktrees/<encoded-name>/<id> in detached HEAD state
  • The worktree’s .git file correctly contains gitdir: /app/.git/worktrees/<id>
  • However, when “Apply” tries to read files from the worktree, it constructs a vscode-remote:// URI instead of using the local filesystem path, which it then cannot resolve

Steps to Reproduce

  1. Create a project with a .devcontainer/devcontainer.json:
{
  "name": "my-devcontainer",
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "workspaceFolder": "/app"
}
  1. Initialize a git repo and make at least one commit:
cd /app
git init
git add .
git commit -m "initial commit"
  1. Open the project in Cursor and attach to the Dev Container.
  2. Open the Agent panel and select “Run in worktree” from the dropdown.
  3. Ask the agent to make any file edit (e.g. “add a comment to file X”).
  4. Wait for the agent to complete.
  5. Click the “Apply” button to merge changes back to the main working tree.

Expected Behavior

Changes from the worktree should be merged into the primary working tree at /app, as described in the Parallel Agents documentation.

Actual Behavior

The Apply button fails with:

Failed to apply worktree to current branch: Unable to read file ‘vscode-remote://dev-container+{hex}/…/filename’

No changes are applied. The worktree changes remain only in the Cursor-managed worktree under ~/.cursor/worktrees/.

Operating System

MacOS
Linux

Version Information

Version: 2.4.22
Commit: 618c607a249dd7fd2ffc662c6531143833bebd40
Arch: arm64

Git Version: 2.39.5

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the detailed report. Your root-cause analysis is spot on.

This is a known issue with how Cursor handles file URIs in remote environments like dev containers and WSL. Instead of using the local file path inside the container, Cursor builds a vscode-remote:// URI, which then can’t be resolved when applying changes from the worktree.

For now, one workaround is to manually apply the changes from the worktree directory ~/.cursor/worktrees/<encoded-name>/<id> using git commands in the container terminal. Not ideal, but it should unblock you.

1 Like