sxyazi/yazi · error
the dist task requires --target
Error message
the dist task requires --target
What it means
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.
Source
Thrown at yazi-build/src/args.rs:34
let mut target = String::new();
let mut bin_dir = PathBuf::new();
while let Some(arg) = args.next() {
match arg.to_str() {
Some("--target") => target = Self::target(&mut args)?,
Some("--bin-dir") => bin_dir = Self::value(&mut args, "--bin-dir")?.into(),
Some("--help") => return Ok(Self::Help),
_ => bail!("unknown option: {}", arg.display()),
}
}
match task.to_str() {
Some("build") => {
ensure!(bin_dir.as_os_str().is_empty(), "--bin-dir is only valid for the install task");
Ok(Self::Build(target))
}
Some("dist") => {
ensure!(!target.is_empty(), "the dist task requires --target");
ensure!(bin_dir.as_os_str().is_empty(), "--bin-dir is only valid for the install task");
Ok(Self::Dest(target))
}
Some("install") => {
ensure!(target.is_empty(), "--target is not valid for the install task");
Ok(Self::Install(bin_dir))
}
Some("--help") => Ok(Self::Help),
_ => bail!("unknown task: {}", task.display()),
}
}
fn value(args: &mut impl Iterator<Item = OsString>, option: &str) -> Result<OsString> {
args.next().with_context(|| format!("missing value for {option}"))
}
fn target(args: &mut impl Iterator<Item = OsString>) -> Result<String> {
Self::value(args, "--target")?View on GitHub (pinned to 5f901b886b)
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
Example fix
// before ya-build dist // after ya-build dist --target x86_64-unknown-linux-gnu
Defensive patterns
Strategy: validation
Validate before calling
if task == "dist" && !args.contains(["--target"]) {
eprintln!("dist requires --target <triple>, e.g. x86_64-unknown-linux-gnu");
std::process::exit(2);
} Try / catch
match parse_result {
Err(e) if e.to_string().contains("the dist task requires --target") => {
eprintln!("usage: ya-build dist --target <rust-target-triple>");
}
other => other,
} Prevention
- 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
When it happens
Trigger: Running `ya-build dist` without `--target <triple>` — the parser reaches the "dist" arm with an empty target.
Common situations: Forgetting the cross-compile target when packaging releases; assuming dist defaults to the host target (it does not).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --bin-dir is only valid for the install task
- --target must be valid UTF-8
- --target is not valid for the install task
- invalid 'args' in SearchOpt
- chafa failed with status: {}
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/149015583b1287b0.
Report an issue: GitHub.