windmill-labs/windmill · error
Error setting R as language: {e}
Error message
Error setting R as language: {e} What it means
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: ...'.
Source
Thrown at backend/parsers/windmill-parser-r/src/lib.rs:19
#![cfg_attr(target_arch = "wasm32", feature(c_variadic))]
#[cfg(target_arch = "wasm32")]
pub mod wasm_libc;
use anyhow::anyhow;
use serde_json::Value;
use tree_sitter::Node;
use tree_sitter::Range;
use windmill_parser::json_to_typ;
use windmill_parser::Arg;
use windmill_parser::MainArgSignature;
pub fn parse_r_sig_meta(code: &str) -> anyhow::Result<MainArgSignature> {
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_r::LANGUAGE;
parser
.set_language(&language.into())
.map_err(|e| anyhow!("Error setting R as language: {e}"))?;
let tree = parser
.parse(code, None)
.ok_or(anyhow!("Failed to parse code"))?;
let root_node = tree.root_node();
let args = find_main_signature(root_node, code)?;
let main_sig = MainArgSignature {
star_args: false,
star_kwargs: false,
args: args.unwrap_or_default(),
has_preprocessor: None,
auto_kind: None,
..Default::default()
};
Ok(main_sig)
}View on GitHub (pinned to e474e8803c)
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.
Example fix
# before (lockfile) tree-sitter = "0.20" tree-sitter-r = "0.24" # after cargo update -p tree-sitter-r # aligned with the tree-sitter core version
Defensive patterns
Strategy: retry
Try / catch
match parse_r_signature(code) {
Err(e) if e.to_string().contains("Error setting R as language") => {
// environment/build issue, not user code: surface as infra error
Err(anyhow!("R grammar failed to load (deployment/build issue): {e}"))
}
other => other,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/91bee2dd0fa8239a.
Report an issue: GitHub.