nikivdev/code · error

`f pr preview --path` requires a value

Error message

`f pr preview --path` requires a value

What it means

The `--path` flag of `f pr preview` requires a repo path value. This error is thrown when --path appears without a following argument.

Source

Thrown at src/pr_preview.rs:299

                index += 1;
            }
            "--mode" => {
                let Some(value) = args.get(index + 1) else {
                    bail!("`f pr preview --mode` requires a value");
                };
                mode = parse_mode_arg(value)?;
                index += 2;
            }
            "--base" => {
                let Some(value) = args.get(index + 1) else {
                    bail!("`f pr preview --base` requires a value");
                };
                requested_base = value.clone();
                index += 2;
            }
            "--path" => {
                let Some(value) = args.get(index + 1) else {
                    bail!("`f pr preview --path` requires a value");
                };
                repo_path = Some(PathBuf::from(value));
                index += 2;
            }
            token => bail!("unknown `f pr preview` option: {token}"),
        }
    }

    Ok(Some(PrPreviewCommand {
        repo_path,
        requested_base,
        mode,
        json,
    }))
}

fn parse_mode_arg(value: &str) -> Result<PrPreviewModeArg> {
    match value.trim().to_ascii_lowercase().as_str() {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Provide the repo directory: `f pr preview --path /path/to/repo`
  2. Verify the variable holding the path is non-empty
  3. Use an absolute or correct relative path

Example fix

// before
f pr preview --path
// after
f pr preview --path ~/repos/api
Defensive patterns

Strategy: validation

Validate before calling

if args.iter().any(|a| a == "--path") {
    let i = args.iter().position(|a| a == "--path").unwrap();
    if args.get(i + 1).is_none() { anyhow::bail!("--path needs a directory"); }
}

Try / catch

if let Err(e) = run_pr_preview(cmd) {
    if e.to_string().contains("--path`) requires a value") {
        eprintln!("Usage: f pr preview --path <repo-dir>");
    }
}

Prevention

When it happens

Trigger: Running `f pr preview --path` with nothing after it, so no PathBuf can be built.

Common situations: Empty environment variable expanded for the path; truncated command in scripts; forgetting the directory argument.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/229e60ba17214f9f. Report an issue: GitHub.