zed-industries/zed · error
failed to compile {grammar_name} parser with clang: {}
Error message
failed to compile {grammar_name} parser with clang: {} What it means
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.
Source
Thrown at crates/extension/src/extension_builder.rs:322
log::info!(
"skipping compilation of {grammar_name} parser because the existing compiled grammar is up to date"
);
} else {
log::info!("compiling {grammar_name} parser");
let clang_output = util::command::new_command(&clang_path)
.args(["-fPIC", "-shared", "-Os"])
.arg(format!("-Wl,--export=tree_sitter_{grammar_name}"))
.arg("-o")
.arg(&grammar_wasm_path)
.arg("-I")
.arg(&src_path)
.arg(&parser_path)
.args(scanner_path.exists().then_some(scanner_path))
.output()
.await
.context("running clang")?;
anyhow::ensure!(
clang_output.status.success(),
"failed to compile {grammar_name} parser with clang: {}",
String::from_utf8_lossy(&clang_output.stderr),
);
}
Ok(())
}
async fn checkout_repo(&self, directory: &Path, url: &str, rev: &str) -> Result<()> {
let git_dir = directory.join(".git");
if directory.exists() {
let remotes_output = util::command::new_command("git")
.arg("--git-dir")
.arg(&git_dir)
.args(["remote", "get-url", "origin"])
.env("GIT_CONFIG_GLOBAL", "/dev/null")View on GitHub (pinned to 9d272b0363)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/extension/src/extension_builder.rs:322 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/9e4174e86f06a7e7.
Report an issue: GitHub.