{"record":{"id":"149015583b1287b0","repo":"sxyazi/yazi","slug":"the-dist-task-requires-target","errorCode":null,"errorMessage":"the dist task requires --target","messagePattern":"the dist task requires --target","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-build/src/args.rs","lineNumber":34,"sourceCode":"\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),\n\t\t\t_ => bail!(\"unknown task: {}\", task.display()),\n\t\t}\n\t}\n\n\tfn value(args: &mut impl Iterator<Item = OsString>, option: &str) -> Result<OsString> {\n\t\targs.next().with_context(|| format!(\"missing value for {option}\"))\n\t}\n\n\tfn target(args: &mut impl Iterator<Item = OsString>) -> Result<String> {\n\t\tSelf::value(args, \"--target\")?","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-build/src/args.rs#L16-L52","documentation":"The `dist` task produces distributable archives per platform, so it requires an explicit `--target` triple; the parser enforces this with `ensure!(!target.is_empty(), ...)` and fails with this error when it's missing.","triggerScenarios":"Running `ya-build dist` without `--target <triple>` — the parser reaches the \"dist\" arm with an empty target.","commonSituations":"Forgetting the cross-compile target when packaging releases; assuming dist defaults to the host target (it does not).","solutions":["Pass an explicit target triple: `ya-build dist --target x86_64-unknown-linux-gnu`","Run `rustup target list-installed` to pick a valid triple","Use the `build` task instead if you only want a native host build"],"exampleFix":"// before\nya-build dist\n// after\nya-build dist --target x86_64-unknown-linux-gnu","handlingStrategy":"validation","validationCode":"if task == \"dist\" && !args.contains([\"--target\"]) {\n    eprintln!(\"dist requires --target <triple>, e.g. x86_64-unknown-linux-gnu\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"match parse_result {\n    Err(e) if e.to_string().contains(\"the dist task requires --target\") => {\n        eprintln!(\"usage: ya-build dist --target <rust-target-triple>\");\n    }\n    other => other,\n}","preventionTips":["Always pass --target with dist; it never defaults to host","Validate triples against `rustup target list-installed`","Script dist calls with the triple as a required parameter"],"tags":["cli","argument-validation","build","cross-compile"],"backgroundTag":"missing-required-argument","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}