zed-industries/zed · error

'.' is ambiguous in multi-root workspaces. Please specify a…

Error message

'.' is ambiguous in multi-root workspaces. Please specify a root directory explicitly.

What it means

working_dir for the terminal tool: the model passed "." (or empty) as the working directory in a multi-root workspace, where the first worktree is ambiguous, so an explicit root directory is required.

Solutions

  1. Pass an explicit root directory path instead of '.' or an empty cd string
  2. Use the absolute path of the intended worktree root when the workspace has multiple roots
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/agent/src/tools/terminal_tool.rs:1349 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/25ebbf1ebdd3f4d1. Report an issue: GitHub.

Appendix: source

Thrown at crates/agent/src/tools/terminal_tool.rs:1349

                        "Command terminated unexpectedly. Output captured:\n\n{}",
                        content
                    )
                }
            }
        }
    };
    content
}

fn working_dir(cd: &str, project: &Entity<Project>, cx: &mut App) -> Result<Option<PathBuf>> {
    let project = project.read(cx);

    if cd == "." || cd.is_empty() {
        let mut worktrees = project.worktrees(cx);

        match worktrees.next() {
            Some(worktree) => {
                anyhow::ensure!(
                    worktrees.next().is_none(),
                    "'.' is ambiguous in multi-root workspaces. Please specify a root directory explicitly.",
                );
                Ok(Some(worktree.read(cx).abs_path().to_path_buf()))
            }
            None => Ok(None),
        }
    } else {
        let path_style = project.path_style(cx);
        let worktree_roots = project
            .worktrees(cx)
            .filter_map(|worktree| {
                let worktree = worktree.read(cx);
                // Skip single-file worktrees: a file can't be a working directory.
                let root_dir = worktree.root_dir()?;
                Some((worktree.root_name_str(), root_dir.to_path_buf()))
            })
            .collect::<Vec<_>>();

View on GitHub (pinned to f4178619ac)