{"record":{"id":"4e359e9cc022a375","repo":"sxyazi/yazi","slug":"target-is-not-valid-for-the-install-task","errorCode":null,"errorMessage":"--target is not valid for the install task","messagePattern":"--target is not valid for the install task","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-build/src/args.rs","lineNumber":39,"sourceCode":"\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\")?\n\t\t\t.into_string()\n\t\t\t.map_err(|_| anyhow!(\"--target must be valid UTF-8\"))\n\t}\n}\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-build/src/args.rs#L21-L57","documentation":"The `yazi-build` CLI (shipped with the `ya` binary) validates that CLI flags are only passed to tasks that accept them. The `install` task copies already-built binaries into the Cargo bin directory, so a cross-compilation `--target` triple is meaningless there; passing one triggers this `ensure!` failure in `Args::parse`. It is an argument-contract error, not a runtime failure.","triggerScenarios":"Running `ya install --target <triple>` (or `ya install --target x86_64-unknown-linux-gnu ...`). `--target` is only accepted by the `build` and `dist` tasks; `install` only accepts `--bin-dir`.","commonSituations":"Users copy-pasting a cross-compile command and swapping `dist` for `install`, or scripting a single arg string reused across build and install steps, accidentally keeping `--target` on the install invocation.","solutions":["Remove the `--target <triple>` argument from the `ya install` command","If you need a specific pre-built binary installed, use `--bin-dir` to point at the directory containing the binaries instead of `--target`","If you meant to cross-compile, run `ya dist --target <triple>` (or `ya build --target <triple>`) first, then `ya install` without `--target`"],"exampleFix":"// before\nya install --target x86_64-unknown-linux-musl\n\n// after\nya install --bin-dir ./target/x86_64-unknown-linux-musl/release\n// or cross-compile first:\nya dist --target x86_64-unknown-linux-musl","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args[0] === 'install' && args.includes('--target')) {\n  throw new Error(\"--target is not valid for 'ya install'; use --bin-dir or 'ya dist --target' instead\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember flag-to-task mapping: --target → build/dist only, --bin-dir → install only","Script install steps without inheriting flags from build/dist command strings","Run `ya --help` to confirm accepted flags per task"],"tags":["cli","argument-validation","build-tooling"],"backgroundTag":"invalid-cli-argument","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"}