zed-industries/zed · error

Failed to create worktree: {err}

Error message

Failed to create worktree: {err}

What it means

Composite error from await_and_rollback_on_failure: worktree creation failed with err, and rollback attempted to delete partially created directories; any cleanup failures (fs_err) are appended under 'Failed to clean up', so the message reports both the root cause and leftover state.

Source

Thrown at crates/git_ui_core/src/worktree_service.rs:626

                    fs::RemoveOptions {
                        recursive: true,
                        ignore_if_not_exists: true,
                    },
                )
                .await
            {
                let msg = format!("{}: failed to remove directory: {fs_err}", path.display());
                log::error!("{}", msg);
                rollback_failures.push(msg);
            }
        }
    }
    let mut error_message = format!("Failed to create worktree: {err}");
    if !rollback_failures.is_empty() {
        error_message.push_str("\n\nFailed to clean up: ");
        error_message.push_str(&rollback_failures.join(", "));
    }
    Err(anyhow!(error_message))
}

/// Propagates worktree trust from the source workspace to the new workspace.
/// If the source project's worktrees are all trusted, the new worktree paths
/// will also be trusted automatically.
fn maybe_propagate_worktree_trust(
    source_workspace: &WeakEntity<Workspace>,
    new_workspace: &Entity<Workspace>,
    paths: &[PathBuf],
    cx: &mut AsyncWindowContext,
) {
    cx.update(|_, cx| {
        if ProjectSettings::get_global(cx).session.trust_all_worktrees {
            return;
        }
        let source_is_trusted = source_workspace
            .upgrade()
            .map(|workspace| {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Read the full error message — it appends any rollback/cleanup failures after 'Failed to clean up:'
  2. Check disk space and filesystem permissions at the target path
  3. Manually remove leftover directories listed in the cleanup failures, then retry
  4. Re-run creation from the worktree picker after resolving the underlying `err`
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/git_ui_core/src/worktree_service.rs:626 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/02477d67aed58a7d. Report an issue: GitHub.