{"record":{"id":"9e4174e86f06a7e7","repo":"zed-industries/zed","slug":"failed-to-compile-grammar-name-parser-with-clang","errorCode":null,"errorMessage":"failed to compile {grammar_name} parser with clang: {}","messagePattern":"failed to compile (.+?) parser with clang: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":322,"sourceCode":"            log::info!(\n                \"skipping compilation of {grammar_name} parser because the existing compiled grammar is up to date\"\n            );\n        } else {\n            log::info!(\"compiling {grammar_name} parser\");\n            let clang_output = util::command::new_command(&clang_path)\n                .args([\"-fPIC\", \"-shared\", \"-Os\"])\n                .arg(format!(\"-Wl,--export=tree_sitter_{grammar_name}\"))\n                .arg(\"-o\")\n                .arg(&grammar_wasm_path)\n                .arg(\"-I\")\n                .arg(&src_path)\n                .arg(&parser_path)\n                .args(scanner_path.exists().then_some(scanner_path))\n                .output()\n                .await\n                .context(\"running clang\")?;\n\n            anyhow::ensure!(\n                clang_output.status.success(),\n                \"failed to compile {grammar_name} parser with clang: {}\",\n                String::from_utf8_lossy(&clang_output.stderr),\n            );\n        }\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\")","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/extension/src/extension_builder.rs#L304-L340","documentation":"Raised in compile_grammar after running clang to build a tree-sitter grammar's native parser shared library: the clang invocation completed but exited with a non-zero status, and the formatted args carry clang's captured stderr. Common underlying causes are a missing C compiler at the resolved clang_path, invalid/older C grammar source that fails to compile, missing headers for the -I include path, or linker errors exporting tree_sitter_<name>. The grammar_name identifies which extension's parser failed.","triggerScenarios":"Thrown at crates/extension/src/extension_builder.rs:322 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install or point to a working clang/CC toolchain and verify with `clang --version`","Read the appended clang diagnostics; fix or upstream-report grammar parser.c errors for the failing grammar","Clear the cached build artifacts for that grammar so a clean recompile is attempted","On misconfigured setups switch the compiler via the clang path setting and confirm the linker supports --export"],"exampleFix":null,"handlingStrategy":"fallback","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"}