{"record":{"id":"4779b7d3873e9a16","repo":"zed-industries/zed","slug":"cargo-toml-not-found-in-current-directory-please-run-this","errorCode":null,"errorMessage":"Cargo.toml not found in current directory. Please run this command from the workspace root.","messagePattern":"Cargo\\.toml not found in current directory\\. Please run this command from the workspace root\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tooling/xtask/src/tasks/gpui.rs","lineNumber":290,"sourceCode":"        .and_then(|p| p.as_table_like_mut())\n    {\n        if let Some(old_entry) = profile_dev_package.get(package_name) {\n            let old_entry_clone = old_entry.clone();\n            profile_dev_package.remove(package_name);\n            profile_dev_package.insert(crate_name, old_entry_clone);\n        }\n    }\n\n    Ok(())\n}\n\nfn check_workspace_root() -> Result<()> {\n    let cwd = std::env::current_dir().context(\"Failed to get current directory\")?;\n\n    // Check if Cargo.toml exists in the current directory\n    let cargo_toml_path = cwd.join(\"Cargo.toml\");\n    if !cargo_toml_path.exists() {\n        bail!(\n            \"Cargo.toml not found in current directory. Please run this command from the workspace root.\"\n        );\n    }\n\n    // Check if it's a workspace by looking for [workspace] section\n    let contents =\n        std::fs::read_to_string(&cargo_toml_path).context(\"Failed to read Cargo.toml\")?;\n\n    if !contents.contains(\"[workspace]\") {\n        bail!(\n            \"Current directory does not appear to be a workspace root. Please run this command from the workspace root.\"\n        );\n    }\n\n    Ok(())\n}\n\nfn check_git_clean() -> Result<()> {","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/tooling/xtask/src/tasks/gpui.rs#L272-L308","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncd crates/gpui\ncargo xtask publish-gpui\n\n// after\ncd \"$(git rev-parse --show-toplevel)\"\ncargo xtask publish-gpui","handlingStrategy":"validation","validationCode":"use std::path::Path;\nif !Path::new(\"Cargo.toml\").exists() {\n    panic!(\"run from the workspace root: {} has no Cargo.toml\", std::env::current_dir()?.display());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cargo","workspace","cli","working-directory"],"backgroundTag":"file-not-found","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-09-19T19:09:50.599Z","contentChangedAt":"2026-09-19T19:09:50.599Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}