helix-editor/helix · error · anyhow::Error
Parser compilation failed. Stdout: {} Stderr: {}
Error message
Parser compilation failed.
Stdout: {}
Stderr: {} What it means
Windows/MSVC branch of grammar compilation: the scanner file (scanner.cc/.cpp) is pre-compiled to an object with cl.exe (/nologo /LD /I<includes> /utf-8 /std:c++14 /c) before linking with the parser, and cl.exe exited non-zero. Stdout/stderr of the compiler are embedded so the real compiler diagnostic is in the message.
Source
Thrown at helix-loader/src/grammar.rs:634
cpp_command.env(key, value);
}
cpp_command.args(compiler.args());
let object_file =
library_path.with_file_name(format!("{}_scanner.obj", &grammar.grammar_id));
cpp_command
.args(["/nologo", "/LD", "/I"])
.arg(header_path)
.arg("/utf-8")
.arg("/std:c++14")
.arg(format!("/Fo{}", object_file.display()))
.arg("/c")
.arg(scanner_path);
let output = cpp_command
.output()
.context("Failed to execute C++ compiler")?;
if !output.status.success() {
return Err(anyhow!(
"Parser compilation failed.\nStdout: {}\nStderr: {}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
));
}
command.arg(&object_file);
_path_guard = TempPath::try_from_path(object_file).unwrap();
}
}
command
.arg(parser_path)
.arg("/link")
.arg(format!("/out:{}", library_path.to_str().unwrap()));
} else {
#[cfg(not(windows))]
command.arg("-fPIC");
View on GitHub (pinned to 079a789e8c)
Solutions
- Run the build from an 'x64 Native Tools Command Prompt' (or vsdevcmd) so cl.exe, INCLUDE and LIB are set
- Read the embedded Stderr - the actual cl diagnostic (C2xxx errors) tells you whether it is headers, arch, or language level
- Install/repair 'Desktop development with C++' workload incl. Windows SDK in Visual Studio Build Tools
- If a specific grammar's scanner needs newer C++, update Helix or override that grammar's source to a compatible revision
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight on Windows: cl.exe must run and target the right arch
fn msvc_ready() -> bool {
std::process::Command::new("cmd").args(["/C", "cl /nologo >nul 2>&1"]).status().map(|s| s.success()).unwrap_or(false)
} Try / catch
// build_grammars returns Result; on failure print the embedded compiler
// stderr so the user sees the cl diagnostic instead of just the wrapper:
if let Err(e) = helix_loader::grammar::build_grammars() {
eprintln!("{e:#}"); // anyhow alternate formatting shows Stdout/Stderr chains
} Prevention
- Run builds from an x64 Native Tools / Developer Command Prompt
- Keep the 'C++ build tools' workload + current Windows SDK installed
- Don't shim cl.exe through wrappers that drop INCLUDE/LIB env vars
When it happens
Trigger: 'hx --grammar build' on Windows where cl.exe runs but fails: C++14-incompatible scanner code, mismatched target architecture (x64 host tools vs 32-bit build), missing Windows SDK / include paths, or scanners needing newer C++ than /std:c++14.
Common situations: Building grammars outside a 'Developer Command Prompt/x64 Native Tools' environment so INCLUDE/LIB env vars are absent; VS Build Tools installed without the C++ workload or SDK; scanner.cc from a newer grammar release using C++17 constructs.
Related errors
- Directory {:?} is empty. Did you use 'hx --grammar fetch'?
- Git command failed. Stdout: {} Stderr: {}
- --grammar must be followed by either 'fetch' or 'build'
- Failed to parse snippet. Remaining input: {}
- Command not provided
AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16).
Data as JSON: /api/errors/09b379b0caf4796b.
Report an issue: GitHub.