denisidoro/navi · error · anyhow

No variables, command, and options found in the line `{}`

Error message

No variables, command, and options found in the line `{}`

What it means

Thrown by `parse_variable_line` in src/parser.rs (called from `read_lines`) when a line in the source file does not match `VAR_LINE_REGEX` at all. The library expects variable-definition lines of the form `<var>: <command> --- [options]`, and any line failing the regex is rejected.

Source

Thrown at src/parser.rs:90

                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_REGEX
        .captures(line)
        .ok_or_else(|| anyhow!("No variables, command, and options found in the line `{}`", line))?;
    let variable = caps
        .get(1)
        .ok_or_else(|| anyhow!("No variable captured in the line `{}`", line))?
        .as_str()
        .trim();
    let mut command_plus_opts = caps
        .get(2)
        .ok_or_else(|| anyhow!("No command and options captured in the line `{}`", line))?
        .as_str()
        .split("---");
    let command = command_plus_opts
        .next()
        .ok_or_else(|| anyhow!("No command captured in the line `{}`", line))?;
    let command_options = command_plus_opts.next().map(parse_opts).transpose()?;
    Ok((variable, command, command_options))
}

fn without_prefix(line: &str) -> String {

View on GitHub (pinned to f7330b9ad5)

Solutions

  1. Rewrite the line to match the expected `<prefix><var>: <command> --- [options]` format
  2. Remove the invalid line or move comments outside the parsed file
  3. Check for stray whitespace/special characters breaking the regex match
  4. Verify you are pointing the tool at the correct file it is meant to parse

Example fix

// before (config line)
this line has no structure at all
// after
my-var: cat file.txt --- --prompt "Pick:"
Defensive patterns

Strategy: validation

Validate before calling

let valid = |line: &str| {
    line.trim().is_empty()
        || line.starts_with(['#', '%', '@']) && line.contains(':')
};
// skip or fix lines for which valid(line) is false before calling the parser

Prevention

When it happens

Trigger: Calling the file-parsing entry point (which walks lines via `read_lines`) on a line missing the required structure: no variable prefix (`#`, `%`, `@`), no `:` separator, or no command after the colon.

Common situations: Malformed config/snippet files after manual editing; comments or prose accidentally left inside the parsed file; wrong file passed to the tool; a changed line format after upgrading where the regex was tightened.

Related errors


AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03). Data as JSON: /api/errors/71b218121649557e. Report an issue: GitHub.