microsoft/edit · error
invalid language: "{}"
Error message
invalid language: "{}" What it means
unicode-gen parses --lang with value_from_fn, accepting only "c" and "rust". Any other value is rejected with `invalid language: "{}"`. This guards generation of Unicode tables to the two supported source-language targets.
Source
Thrown at crates/unicode-gen/src/main.rs:266
--no-ambiguous Treat all ambiguous characters as narrow
--line-breaks Store and expose line break information
Download ucd.nounihan.grouped.xml at:
https://www.unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip
";
fn main() -> anyhow::Result<()> {
let mut args = pico_args::Arguments::from_env();
if args.contains(["-h", "--help"]) {
eprint!("{HELP}");
return Ok(());
}
let mut out = Output {
arg_lang: args.value_from_fn("--lang", |arg| match arg {
"c" => Ok(Language::C),
"rust" => Ok(Language::Rust),
l => bail!("invalid language: \"{}\"", l),
})?,
arg_extended: args.contains("--extended"),
arg_no_ambiguous: args.contains("--no-ambiguous"),
arg_line_breaks: args.contains("--line-breaks"),
..Default::default()
};
let arg_input = args.free_from_os_str(|s| -> Result<PathBuf, &'static str> { Ok(s.into()) })?;
let arg_remaining = args.finish();
if !arg_remaining.is_empty() {
bail!("unrecognized arguments: {:?}", arg_remaining);
}
let input = std::fs::read_to_string(arg_input)?;
let doc = roxmltree::Document::parse(&input)?;
out.ucd = extract_values_from_ucd(&doc, &out)?;
// Find the best trie configuration over the given block sizes (2^2 - 2^8) and stages (4).
// More stages = Less size. The trajectory roughly follows a+b*c^stages, where c < 1.View on GitHub (pinned to 826b4c097b)
Solutions
- Use --lang c or --lang rust exactly (lowercase).
- If you need another target, extend the match arm in main.rs to map the new string to a Language variant.
- Check the binary's usage/help for the supported language list.
Example fix
// before unicode-gen --lang=cpp GraphemeBreakProperty.txt // after unicode-gen --lang=c GraphemeBreakProperty.txt
Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED: &[&str] = &["c", "rust"];
let lang = std::env::args().find(|a| a.starts_with("--lang")).map(|a| a.split('=').nth(1).unwrap_or("")).unwrap_or("");
assert!(SUPPORTED.contains(&lang), "--lang must be c or rust, got {lang}"); Prevention
- Only pass --lang c or --lang rust (exact lowercase).
- Pin the unicode-gen invocation in scripts/Makefiles with the fixed valid value.
- If a new target is needed, extend the Language enum in the generator source first.
When it happens
Trigger: Running unicode-gen with --lang set to anything other than `c` or `rust`, e.g. --lang=cpp, --lang=python, or a misspelling like --lang=Rust (case-sensitive).
Common situations: Assuming other output languages are supported; shell completion offering stale values; case mistakes since the matcher is exact lowercase.
Understand the failure class
Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.
Related errors
- At least one .lsh file or directory is required
- A language ID is required when reading from stdin
- No highlighting definition found for language {language:?}
- No matching highlighting definition found
- unrecognized arguments: {:?}
AI-assisted analysis of microsoft/edit@826b4c097b (2026-09-06).
Data as JSON: /api/errors/88ad6a5b003b70b7.
Report an issue: GitHub.