{"record":{"id":"532a8047e7316ed6","repo":"zed-industries/zed","slug":"grammar-directory-directory-already-exists-but-is-not-a-git","errorCode":null,"errorMessage":"grammar directory {directory:?} already exists, but is not a git clone of '{url}'","messagePattern":"grammar directory (.+?) already exists, but is not a git clone of '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":345,"sourceCode":"        }\n\n        Ok(())\n    }\n\n    async fn checkout_repo(&self, directory: &Path, url: &str, rev: &str) -> Result<()> {\n        let git_dir = directory.join(\".git\");\n\n        if directory.exists() {\n            let remotes_output = util::command::new_command(\"git\")\n                .arg(\"--git-dir\")\n                .arg(&git_dir)\n                .args([\"remote\", \"get-url\", \"origin\"])\n                .env(\"GIT_CONFIG_GLOBAL\", \"/dev/null\")\n                .output()\n                .await?;\n            let has_remote = remotes_output.status.success()\n                && String::from_utf8_lossy(&remotes_output.stdout).trim() == url;\n            anyhow::ensure!(\n                has_remote,\n                \"grammar directory {directory:?} already exists, but is not a git clone of '{url}'\"\n            );\n        } else {\n            fs::create_dir_all(directory)\n                .with_context(|| format!(\"creating grammar directory {directory:?}\"))?;\n            let init_output = util::command::new_command(\"git\")\n                .arg(\"init\")\n                .current_dir(directory)\n                .output()\n                .await?;\n            anyhow::ensure!(\n                init_output.status.success(),\n                \"failed to run `git init` in directory {directory:?}\"\n            );\n\n            let remote_add_output = util::command::new_command(\"git\")\n                .arg(\"--git-dir\")","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/extension/src/extension_builder.rs#L327-L363","documentation":"A guard in checkout_repo: the target grammar directory already exists, so the builder refuses to overwrite it, but `git remote get-url origin` (run with GIT_CONFIG_GLOBAL=/dev/null) reported a remote different from the expected url. This means the cache directory holds a clone of some other repository (or a non-clone left by an earlier failed run), and reusing it would compile the wrong grammar. The inputs at fault are the existing directory contents and the url from the extension's grammar manifest.","triggerScenarios":"Thrown at crates/extension/src/extension_builder.rs:345 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the stale grammar directory (or the whole grammar cache) so checkout_repo performs a fresh clone of the correct url","Check the extension's grammar manifest url for typos or an outdated fork URL pointing at a different repo","If the url moved intentionally, clear the old cache once so the new remote is recorded"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}