denisidoro/navi · error · anyhow
No value provided for the flag `{}`
Error message
No value provided for the flag `{}` What it means
Thrown by `parse_opts` in src/parser.rs when an option flag appears as a chunk with no paired value. Options are split into (flag, value) pairs of 2; a lone flag that expects a value yields a 1-element chunk and produces this error, wrapped with the context "Failed to parse finder options".
Source
Thrown at src/parser.rs:70
opts.column = Some(
value
.parse::<u8>()
.context("Value for `--column` is invalid u8")?,
)
}
"--map" => opts.map = Some(value.to_string()),
"--delimiter" => opts.delimiter = Some(value.to_string()),
"--query" => opts.query = Some(value.to_string()),
"--filter" => opts.filter = Some(value.to_string()),
"--preview" => opts.preview = Some(value.to_string()),
"--preview-window" => opts.preview_window = Some(value.to_string()),
"--header" => opts.header = Some(value.to_string()),
"--fzf-overrides" => opts.overrides = Some(value.to_string()),
_ => (),
}
Ok(())
} else if let [flag] = flag_and_value {
Err(anyhow!("No value provided for the flag `{}`", flag))
} else {
unreachable!() // Chunking by 2 allows only for tuples of 1 or 2 items...
}
})
.context("Failed to parse finder options")?;
let suggestion_type = match (multi, prevent_extra) {
(true, _) => SuggestionType::MultipleSelections, // multi wins over prevent-extra
(false, false) => SuggestionType::SingleRecommendation,
(false, true) => SuggestionType::SingleSelection,
};
opts.suggestion_type = suggestion_type;
Ok(opts)
}
fn parse_variable_line(line: &str) -> Result<(&str, &str, Option<FinderOpts>)> {
let caps = VAR_LINE_REGEXView on GitHub (pinned to f7330b9ad5)
Solutions
- Provide the missing value after the flag, e.g. `--prompt "Select:"`
- Remove the dangling flag entirely if the option is not needed
- Check the config line for accidental line breaks or truncation that dropped the value
- Use `--fzf-overrides` quoting correctly so the flag and its value stay paired
Example fix
// before my-var: cat file.txt --- --prompt // after my-var: cat file.txt --- --prompt "Select a file:"
Defensive patterns
Strategy: validation
Validate before calling
fn every_flag_has_value(opts: &str) -> bool {
let toks: Vec<&str> = opts.split_whitespace().collect();
toks.iter().enumerate().all(|(i, t)| {
!(t.starts_with("--") && *t != "--header" && *t != "--prompt"
&& *t != "--fzf-overrides"
&& t.starts_with("--header")
|| t.starts_with("--") && (t == &"--header" || t == &"--prompt" || t == &"--fzf-overrides")
&& toks.get(i + 1).map_or(true, |v| v.starts_with("--")))
})
}
// simpler: grep the options string for a flag at the end: opts.trim_end().ends_with(any value-taking flag) Prevention
- Always write flag and value together: `--prompt "text"`
- Check config lines for truncation after edits
- Validate the whole options line in a shell before saving
When it happens
Trigger: A finder options string containing a value-taking flag like `--header`, `--prompt`, or `--fzf-overrides` with nothing after it, e.g. `--- --prompt` or trailing whitespace stripping away the value.
Common situations: Deleting an option's value while editing a config but leaving the flag; line breaks in a config file dropping the value; typos where the value was written as a separate option.
Related errors
- Given options are missing a closing quote
- No variables, command, and options found in the line `{}`
- No variable captured in the line `{}`
- No command and options captured in the line `{}`
- No command captured in the line `{}`
AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03).
Data as JSON: /api/errors/297f57e30612cf65.
Report an issue: GitHub.