{"record":{"id":"09b379b0caf4796b","repo":"helix-editor/helix","slug":"parser-compilation-failed-stdout-stderr","errorCode":null,"errorMessage":"Parser compilation failed.\nStdout: {}\nStderr: {}","messagePattern":"Parser compilation failed\\.\nStdout: (.+?)\nStderr: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-loader/src/grammar.rs","lineNumber":634,"sourceCode":"                    cpp_command.env(key, value);\n                }\n                cpp_command.args(compiler.args());\n                let object_file =\n                    library_path.with_file_name(format!(\"{}_scanner.obj\", &grammar.grammar_id));\n                cpp_command\n                    .args([\"/nologo\", \"/LD\", \"/I\"])\n                    .arg(header_path)\n                    .arg(\"/utf-8\")\n                    .arg(\"/std:c++14\")\n                    .arg(format!(\"/Fo{}\", object_file.display()))\n                    .arg(\"/c\")\n                    .arg(scanner_path);\n                let output = cpp_command\n                    .output()\n                    .context(\"Failed to execute C++ compiler\")?;\n\n                if !output.status.success() {\n                    return Err(anyhow!(\n                        \"Parser compilation failed.\\nStdout: {}\\nStderr: {}\",\n                        String::from_utf8_lossy(&output.stdout),\n                        String::from_utf8_lossy(&output.stderr)\n                    ));\n                }\n                command.arg(&object_file);\n                _path_guard = TempPath::try_from_path(object_file).unwrap();\n            }\n        }\n\n        command\n            .arg(parser_path)\n            .arg(\"/link\")\n            .arg(format!(\"/out:{}\", library_path.to_str().unwrap()));\n    } else {\n        #[cfg(not(windows))]\n        command.arg(\"-fPIC\");\n","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-loader/src/grammar.rs#L616-L652","documentation":"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.","triggerScenarios":"'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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight on Windows: cl.exe must run and target the right arch\nfn msvc_ready() -> bool {\n    std::process::Command::new(\"cmd\").args([\"/C\", \"cl /nologo >nul 2>&1\"]).status().map(|s| s.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"// build_grammars returns Result; on failure print the embedded compiler\n// stderr so the user sees the cl diagnostic instead of just the wrapper:\nif let Err(e) = helix_loader::grammar::build_grammars() {\n    eprintln!(\"{e:#}\"); // anyhow alternate formatting shows Stdout/Stderr chains\n}","preventionTips":["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"],"tags":["rust","helix","grammar","tree-sitter","build","windows","msvc"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}