{"record":{"id":"13ad7db6eea4188f","repo":"helix-editor/helix","slug":"grammar-must-be-followed-by-either-fetch-or-b","errorCode":null,"errorMessage":"--grammar must be followed by either 'fetch' or 'build'","messagePattern":"--grammar must be followed by either 'fetch' or 'build'","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helix-term/src/args.rs","lineNumber":69,"sourceCode":"                \"--strict\" => args.strict = true,\n                \"--tutor\" => args.load_tutor = true,\n                \"--vsplit\" => match args.split {\n                    Some(_) => anyhow::bail!(\"can only set a split once of a specific type\"),\n                    None => args.split = Some(Layout::Vertical),\n                },\n                \"--hsplit\" => match args.split {\n                    Some(_) => anyhow::bail!(\"can only set a split once of a specific type\"),\n                    None => args.split = Some(Layout::Horizontal),\n                },\n                \"--health\" => {\n                    args.health = true;\n                    args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));\n                }\n                \"-g\" | \"--grammar\" => match argv.next().as_deref() {\n                    Some(\"fetch\") => args.fetch_grammars = true,\n                    Some(\"build\") => args.build_grammars = true,\n                    _ => {\n                        anyhow::bail!(\"--grammar must be followed by either 'fetch' or 'build'\")\n                    }\n                },\n                \"-c\" | \"--config\" => match argv.next().as_deref() {\n                    Some(path) => args.config_file = Some(path.into()),\n                    None => anyhow::bail!(\"--config must specify a path to read\"),\n                },\n                \"--log\" => match argv.next().as_deref() {\n                    Some(path) => args.log_file = Some(path.into()),\n                    None => anyhow::bail!(\"--log must specify a path to write\"),\n                },\n                \"-w\" | \"--working-dir\" => match argv.next().as_deref() {\n                    Some(path) => {\n                        args.working_directory = if Path::new(path).is_dir() {\n                            Some(PathBuf::from(path))\n                        } else {\n                            anyhow::bail!(\n                                \"--working-dir specified does not exist or is not a directory\"\n                            )","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-term/src/args.rs#L51-L87","documentation":"The -g/--grammar option requires exactly one value: 'fetch' or 'build'. Any other following token - including another flag like '-v', a missing value at end of argv, or a misspelled word - hits the catch-all arm and bails with this message.","triggerScenarios":"'hx -g' as the last argument; 'hx --grammar install'; 'hx -g fetch extra'; 'hx -g --build' (value starts with '-' so argv.next() yields '--build', not 'build').","commonSituations":"Assuming a 'grammar install'/'update' subcommand exists; scripts calling 'hx --grammar ${ACTION}' with an unset/empty ACTION variable; typo 'buil'/'fetched'.","solutions":["Use exactly: hx --grammar fetch  or  hx --grammar build","In scripts, default the variable: ACTION=${ACTION:-fetch} before interpolating","Remember fetch (downloads sources via git) must precede build (compiles them)"],"exampleFix":"# before\nhx -g        # no value\nhx --grammar install   # wrong verb\n\n# after\nhx --grammar fetch\nhx --grammar build","handlingStrategy":"validation","validationCode":"# Script guard: only allow the two legal verbs\nACTION=\"${1:-fetch}\"\ncase \"$ACTION\" in fetch|build) ;; *) echo \"usage: $0 [fetch|build]\"; exit 2;; esac\nexec hx --grammar \"$ACTION\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly 'hx --grammar fetch' or 'hx --grammar build'","Default-validate interpolated ACTION variables in scripts","Fetch precedes build - chain them explicitly"],"tags":["rust","helix","cli","args","grammar"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}