zed-industries/zed · error

Current directory does not appear to be a workspace root…

Error message

Current directory does not appear to be a workspace root. Please run this command from the workspace root.

What it means

Also thrown by `check_workspace_root` (tooling/xtask/src/tasks/gpui.rs:300). A Cargo.toml exists in the current directory, but its contents do not contain a `[workspace]` section, so the directory is not the workspace root the publish pipeline requires. This prevents publishing against a standalone crate manifest by mistake.

Solutions

  1. Run the command from the monorepo root whose Cargo.toml contains [workspace] (usually the git repo root).
  2. If you believe the directory IS the root, check the root Cargo.toml still declares `[workspace]` and restore it if missing.
  3. Confirm with `grep -l '^\[workspace\]' Cargo.toml` in the intended directory before running.

Example fix

# before (crate Cargo.toml, no workspace section)
[package]
name = "gpui"

# after — run from root manifest
[workspace]
members = ["crates/*"]
Defensive patterns

Strategy: validation

Validate before calling

let contents = std::fs::read_to_string("Cargo.toml")?;
assert!(contents.contains("[workspace]"), "current directory is not a workspace root");

Prevention

When it happens

Trigger: Running the publish xtask from a nested crate whose Cargo.toml has only [package], or from a non-workspace Cargo project; a root manifest where the [workspace] section was accidentally removed or renamed.

Common situations: Running from a vendored/sub-project directory; publishing a crate extracted from the monorepo; a broken merge that dropped the [workspace] table from the root Cargo.toml.

Related errors


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19). Data as JSON: /api/errors/be599b68bee32463. Report an issue: GitHub.

Appendix: source

Thrown at tooling/xtask/src/tasks/gpui.rs:300

}

fn check_workspace_root() -> Result<()> {
    let cwd = std::env::current_dir().context("Failed to get current directory")?;

    // Check if Cargo.toml exists in the current directory
    let cargo_toml_path = cwd.join("Cargo.toml");
    if !cargo_toml_path.exists() {
        bail!(
            "Cargo.toml not found in current directory. Please run this command from the workspace root."
        );
    }

    // Check if it's a workspace by looking for [workspace] section
    let contents =
        std::fs::read_to_string(&cargo_toml_path).context("Failed to read Cargo.toml")?;

    if !contents.contains("[workspace]") {
        bail!(
            "Current directory does not appear to be a workspace root. Please run this command from the workspace root."
        );
    }

    Ok(())
}

fn check_git_clean() -> Result<()> {
    let output = run_command(
        Command::new("git")
            .args(["status", "--porcelain"])
            .stdout(Stdio::piped())
            .stderr(Stdio::piped()),
    )?;

    if !output.status.success() {
        bail!("git status command failed");
    }

View on GitHub (pinned to 916fc2b8cb)