{"record":{"id":"91bee2dd0fa8239a","repo":"windmill-labs/windmill","slug":"error-setting-r-as-language-e","errorCode":null,"errorMessage":"Error setting R as language: {e}","messagePattern":"Error setting R as language: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-r/src/lib.rs","lineNumber":19,"sourceCode":"#![cfg_attr(target_arch = \"wasm32\", feature(c_variadic))]\n\n#[cfg(target_arch = \"wasm32\")]\npub mod wasm_libc;\n\nuse anyhow::anyhow;\nuse serde_json::Value;\nuse tree_sitter::Node;\nuse tree_sitter::Range;\nuse windmill_parser::json_to_typ;\nuse windmill_parser::Arg;\nuse windmill_parser::MainArgSignature;\n\npub fn parse_r_sig_meta(code: &str) -> anyhow::Result<MainArgSignature> {\n    let mut parser = tree_sitter::Parser::new();\n    let language = tree_sitter_r::LANGUAGE;\n    parser\n        .set_language(&language.into())\n        .map_err(|e| anyhow!(\"Error setting R as language: {e}\"))?;\n\n    let tree = parser\n        .parse(code, None)\n        .ok_or(anyhow!(\"Failed to parse code\"))?;\n    let root_node = tree.root_node();\n\n    let args = find_main_signature(root_node, code)?;\n    let main_sig = MainArgSignature {\n        star_args: false,\n        star_kwargs: false,\n        args: args.unwrap_or_default(),\n        has_preprocessor: None,\n        auto_kind: None,\n        ..Default::default()\n    };\n\n    Ok(main_sig)\n}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/lib.rs#L1-L37","documentation":"parse_r_sig_meta in windmill-parser-r initializes a tree-sitter parser for R via parser.set_language(tree_sitter_r::LANGUAGE). Failure here means the tree-sitter runtime could not load/accept the R grammar (version or ABI incompatibility between tree-sitter and the language crate), and the parser throws 'Error setting R as language: ...'.","triggerScenarios":"Calling parse_r_sig_meta (via parse_r_signature) when set_language rejects the grammar — typically a tree-sitter core / tree-sitter-r version mismatch in the build, or an unsafe/ABI issue in the compiled grammar, not anything in the user's R code.","commonSituations":"Building windmill with mismatched tree-sitter crate versions in the lockfile, a toolchain/FFI issue on the target platform, or an upgrade of tree-sitter without regenerating/upgrading tree-sitter-r.","solutions":["Check Cargo.lock for tree-sitter and tree-sitter-r version compatibility; align tree-sitter-r to the tree-sitter core version in use.","Run 'cargo update -p tree-sitter-r' (or pin both) and rebuild the backend.","Rebuild from a clean target/ to rule out stale FFI artifacts between grammar versions.","If it persists, file an issue with the backend build log — the user's R code content is irrelevant here."],"exampleFix":"# before (lockfile)\ntree-sitter = \"0.20\"\ntree-sitter-r = \"0.24\"\n\n# after\ncargo update -p tree-sitter-r  # aligned with the tree-sitter core version","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match parse_r_signature(code) {\n    Err(e) if e.to_string().contains(\"Error setting R as language\") => {\n        // environment/build issue, not user code: surface as infra error\n        Err(anyhow!(\"R grammar failed to load (deployment/build issue): {e}\"))\n    }\n    other => other,\n}","preventionTips":["Pin compatible tree-sitter and tree-sitter-r versions in Cargo.lock","Rebuild backend with a clean target/ after upgrading tree-sitter crates","Run a smoke R script parse after every backend build that touches tree-sitter","Recognize this is never caused by the user's R code — route to infra, not the author"],"tags":["r","tree-sitter","grammar","build"],"backgroundTag":"tree-sitter-language-load-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}