zed-industries/zed · error

Failed to stage paths: {}

Error message

Failed to stage paths:
{}

What it means

ensure! guard failing when `git update-index --add --remove -- <paths...>` exits non-zero while staging a batch of paths. Commonly caused by a locked index, paths outside the repository, or unreadable files.

Source

Thrown at crates/git/src/repository.rs:2498

    }

    fn stage_paths(
        &self,
        paths: Vec<RepoPath>,
        env: Arc<HashMap<String, String>>,
    ) -> BoxFuture<'_, Result<()>> {
        let git = self.git_binary_in_worktree();
        self.executor
            .spawn(async move {
                let git = git?;
                if !paths.is_empty() {
                    let output = git
                        .build_command(&["update-index", "--add", "--remove", "--"])
                        .envs(env.iter())
                        .args(paths.iter().map(|p| p.as_unix_str()))
                        .output()
                        .await?;
                    anyhow::ensure!(
                        output.status.success(),
                        "Failed to stage paths:\n{}",
                        String::from_utf8_lossy(&output.stderr),
                    );
                }
                Ok(())
            })
            .boxed()
    }

    fn unstage_paths(
        &self,
        paths: Vec<RepoPath>,
        env: Arc<HashMap<String, String>>,
    ) -> BoxFuture<'_, Result<()>> {
        let git = self.git_binary_in_worktree();

        self.executor

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check git stderr embedded in the error for the offending path
  2. Remove a stale .git/index.lock and retry
  3. Ensure all requested paths are inside the repo worktree
  4. Retry staging the paths individually to isolate the failing one
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/git/src/repository.rs:2498 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/cbd7879931bc3521. Report an issue: GitHub.