{"record":{"id":"f896b99774c0f0e0","repo":"zed-industries/zed","slug":"git-status-command-failed","errorCode":null,"errorMessage":"git status command failed","messagePattern":"git status command failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tooling/xtask/src/tasks/gpui.rs","lineNumber":317,"sourceCode":"    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<()> {\n    let output = run_command(\n        Command::new(\"git\")\n            .args([\"status\", \"--porcelain\"])\n            .stdout(Stdio::piped())\n            .stderr(Stdio::piped()),\n    )?;\n\n    if !output.status.success() {\n        bail!(\"git status command failed\");\n    }\n\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    if !stdout.trim().is_empty() {\n        bail!(\n            \"Working directory is not clean. Please commit or stash your changes before publishing.\"\n        );\n    }\n\n    Ok(())\n}\n\nfn run_command(command: &mut Command) -> Result<Output> {\n    let command_str = {\n        let program = command.get_program().to_string_lossy();\n        let args = command\n            .get_args()\n            .map(|arg| arg.to_string_lossy())","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/tooling/xtask/src/tasks/gpui.rs#L299-L335","documentation":"Thrown by `check_git_clean` (tooling/xtask/src/tasks/gpui.rs:317) when the spawned `git status --porcelain` command exits unsuccessfully. The publish flow needs a clean working tree to safely mutate manifests and commit release changes, so it first verifies git itself reports a clean state and aborts if git fails.","triggerScenarios":"git is unavailable or fails in the current directory (not a git repo, corrupt .git, bad gitconfig, permission issues) so `git status --porcelain` returns a non-zero status during run_publish_gpui.","commonSituations":"Running xtask outside a git clone (e.g. an exported source tarball); a broken GIT_DIR/GIT_WORK_TREE environment; git hooks/config errors; a detached or inaccessible .git directory.","solutions":["Run `git status --porcelain` manually to see git's underlying error and fix it (init/clone the repo, fix config, correct GIT_DIR).","Run the publish command from within the actual git checkout of the repository.","Check git installation and permissions (`which git; git --version`), then retry.","Clear stray GIT_DIR/GIT_WORK_TREE environment variables that may point git at the wrong location."],"exampleFix":"// before (exported tarball, no .git)\ncd extracted-source\ncargo xtask publish-gpui\n\n// after\ngit clone git@github.com:zed-industries/zed.git\ncd zed\ncargo xtask publish-gpui","handlingStrategy":"try-catch","validationCode":"let output = std::process::Command::new(\"git\").args([\"status\", \"--porcelain\"]).output()?;\nif !output.status.success() {\n    eprintln!(\"git failed: {}\", String::from_utf8_lossy(&output.stderr));\n}","typeGuard":null,"tryCatchPattern":"match Command::new(\"git\").args([\"status\", \"--porcelain\"]).output() {\n    Ok(o) if o.status.success() => { /* proceed */ }\n    Ok(o) => eprintln!(\"git status failed: {}\", String::from_utf8_lossy(&o.stderr)),\n    Err(e) => eprintln!(\"could not run git: {e}\"),\n}","preventionTips":["Always run publish from a proper git clone, not an exported tarball.","Run `git status --porcelain` manually first to surface git config/environment problems.","Unset stray GIT_DIR/GIT_WORK_TREE variables in publish scripts."],"tags":["git","cli","publishing","working-directory"],"backgroundTag":"git-command-failed","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"}