zed-industries/zed · error
Cargo.toml not found in current directory. Please run this…
Error message
Cargo.toml not found in current directory. Please run this command from the workspace root.
What it means
Thrown by `check_workspace_root` (tooling/xtask/src/tasks/gpui.rs:290) at the start of run_publish_gpui. The publish commands mutate the root workspace manifest, so the tool verifies that a Cargo.toml exists in the current working directory; if not, it aborts with instructions to run from the workspace root.
Solutions
- cd to the repository root (the directory containing the workspace Cargo.toml) and re-run the command.
- In scripts/CI, add `working-directory: <repo root>` or `cd "$(git rev-parse --show-toplevel)"` before invoking xtask.
- Verify with `ls Cargo.toml && grep '\[workspace\]' Cargo.toml` before running.
Example fix
// before cd crates/gpui cargo xtask publish-gpui // after cd "$(git rev-parse --show-toplevel)" cargo xtask publish-gpui
Defensive patterns
Strategy: validation
Validate before calling
use std::path::Path;
if !Path::new("Cargo.toml").exists() {
panic!("run from the workspace root: {} has no Cargo.toml", std::env::current_dir()?.display());
} Prevention
- Run publish commands from the git repo root: `cd "$(git rev-parse --show-toplevel)"`.
- Set explicit working-directory in CI jobs and wrapper scripts.
- Check `ls Cargo.toml` before running any xtask publish subcommand.
When it happens
Trigger: Invoking `cargo xtask publish-gpui` (or the equivalent package publish subcommand) from a subdirectory such as crates/gpui, a checkout subfolder, or any directory lacking Cargo.toml.
Common situations: Running the command from inside a crate directory; running from a temp/build dir; an IDE terminal opened at a nested path; publish scripts with a different cwd than expected.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Current directory does not appear to be a workspace root…
- git status command failed
- no GPUI crates found in the workspace
- `cd` directory was not in any root directory in the project.
- Command failed with status
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19).
Data as JSON: /api/errors/4779b7d3873e9a16.
Report an issue: GitHub.
Appendix: source
Thrown at tooling/xtask/src/tasks/gpui.rs:290
.and_then(|p| p.as_table_like_mut())
{
if let Some(old_entry) = profile_dev_package.get(package_name) {
let old_entry_clone = old_entry.clone();
profile_dev_package.remove(package_name);
profile_dev_package.insert(crate_name, old_entry_clone);
}
}
Ok(())
}
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<()> {View on GitHub (pinned to 916fc2b8cb)