{"record":{"id":"425bf2f633d83abd","repo":"sxyazi/yazi","slug":"unknown-option","errorCode":null,"errorMessage":"unknown option: {}","messagePattern":"unknown option: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-build/src/args.rs","lineNumber":24,"sourceCode":"\tBuild(String),\n\tDest(String),\n\tInstall(PathBuf),\n\tHelp,\n}\n\nimpl Args {\n\tpub(super) fn parse() -> Result<Self> {\n\t\tlet mut args = env::args_os().skip(1);\n\t\tlet task = args.next().unwrap_or_else(|| \"--help\".into());\n\n\t\tlet mut target = String::new();\n\t\tlet mut bin_dir = PathBuf::new();\n\t\twhile let Some(arg) = args.next() {\n\t\t\tmatch arg.to_str() {\n\t\t\t\tSome(\"--target\") => target = Self::target(&mut args)?,\n\t\t\t\tSome(\"--bin-dir\") => bin_dir = Self::value(&mut args, \"--bin-dir\")?.into(),\n\t\t\t\tSome(\"--help\") => return Ok(Self::Help),\n\t\t\t\t_ => bail!(\"unknown option: {}\", arg.display()),\n\t\t\t}\n\t\t}\n\n\t\tmatch task.to_str() {\n\t\t\tSome(\"build\") => {\n\t\t\t\tensure!(bin_dir.as_os_str().is_empty(), \"--bin-dir is only valid for the install task\");\n\t\t\t\tOk(Self::Build(target))\n\t\t\t}\n\t\t\tSome(\"dist\") => {\n\t\t\t\tensure!(!target.is_empty(), \"the dist task requires --target\");\n\t\t\t\tensure!(bin_dir.as_os_str().is_empty(), \"--bin-dir is only valid for the install task\");\n\t\t\t\tOk(Self::Dest(target))\n\t\t\t}\n\t\t\tSome(\"install\") => {\n\t\t\t\tensure!(target.is_empty(), \"--target is not valid for the install task\");\n\t\t\t\tOk(Self::Install(bin_dir))\n\t\t\t}\n\t\t\tSome(\"--help\") => Ok(Self::Help),","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-build/src/args.rs#L6-L42","documentation":"The `yazi-build` argument parser only accepts the flags `--target`, `--bin-dir`, and `--help` while iterating over CLI arguments. Any argument that is not one of these (and is not the task name `build` or `install`) causes the parser to bail with `unknown option: <arg>`. It is a usage/CLI contract error thrown from `Args::parse` in yazi-build/src/args.rs.","triggerScenarios":"Running `cargo yazi --some-flag ...` or `cargo yazi build --foo` with a flag not in {`--target`, `--bin-dir`, `--help`}; misspelling a flag (e.g. `--bin_dir` or `--targe`); passing positional junk arguments.","commonSituations":"Typo in a flag in a script or Makefile; copying flags from an older version of the build helper that supported different options; putting `--bin-dir` before the `build` task and confusing the parser ordering.","solutions":["Check the argument spelling against the supported set: `--target <triple>`, `--bin-dir <path>`, `--help`, and the task names `build`/`install`.","Run with `--help` (or read yazi-build/src/args.rs) to list the accepted options for your version.","Fix the invoker (script, CI config, cargo alias in .cargo/config.toml) to pass only supported flags."],"exampleFix":"// before\ncargo yazi build --prefix ~/.local\n// after\ncargo yazi install --bin-dir ~/.local/bin","handlingStrategy":"validation","validationCode":"const VALID_OPTS = [\"--target\", \"--bin-dir\", \"--help\"];\nif (!VALID_OPTS.includes(arg) && ![\"build\", \"install\"].includes(task)) {\n  throw new Error(`unknown option: ${arg} (valid: ${VALID_OPTS.join(\", \")})`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `cargo yazi --help` before scripting unfamiliar flags.","Keep cargo aliases (.cargo/config.toml) in sync with the supported flag set.","Prefer `--bin-dir` only with the `install` task to avoid option/task misuse."],"tags":["cli","argument-parsing","usage-error"],"backgroundTag":"unknown-cli-option","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}