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

The terminal tool derives a command's working directory from the `cd` parameter. When cd is '.' or empty it defaults to the project's sole worktree root — but only when exactly one worktree exists. In a multi-root workspace there is no unambiguous default, so the tool errors out rather than silently pick the first root.

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 bc538def45)

Solutions

  1. Pass an explicit cd: the worktree's root name (as shown in the project panel) or an absolute path under the desired root
  2. Remove the extra folder from the project if it was added by accident

Example fix

// before
run_terminal_command(command="cargo test", cd=".")

// after — name the root explicitly in a multi-root project
run_terminal_command(command="cargo test", cd="my-app")
Defensive patterns

Strategy: validation

Validate before calling

let worktree_count = project.read(cx).worktrees(cx).count();
if worktree_count > 1 {
    // require an explicit cd (root name or absolute path) for terminal commands
}

Try / catch

Catch the ambiguity message and re-issue the command with cd set to a specific worktree root name or absolute root path.

Prevention

When it happens

Trigger: An agent terminal/exec tool call with cd='.' (or cd omitted) in a project with two or more open worktrees (multiple folders added to the project).

Common situations: A second folder is added to the workspace and prompts that used to run fine now fail at working-directory resolution; the user does not realize the project is multi-root.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/25ebbf1ebdd3f4d1. Report an issue: GitHub.