denisidoro/navi · warning · anyhow

No URL specified

Error message

No URL specified

What it means

`common::url::open` opens a URL in the user's browser via an embedded shell script. It takes the URL from the first argument of the args Vec; if the Vec is empty, `.next()` yields None and it returns `anyhow!("No URL specified")`. It's a guard against calling the opener with nothing to open.

Source

Thrown at src/common/url.rs:10

use crate::common::shell::{self, ShellSpawnError};
use crate::prelude::*;
use anyhow::Result;
use shell::EOF;

pub fn open(args: Vec<String>) -> Result<()> {
    let url = args
        .into_iter()
        .next()
        .ok_or_else(|| anyhow!("No URL specified"))?;
    let code = r#"
exst() {
   type "$1" &>/dev/null
}

_open_url() { 
    local -r url="$1"
    if exst xdg-open; then
        xdg-open "$url" &disown
    elif exst open; then
        echo "$url" | xargs -I% open "%"
    else
        exit 55
    fi
}"#;
    let cmd = format!(
        r#"{code}
                

View on GitHub (pinned to f7330b9ad5)

Solutions

  1. Pass the URL as the first argument: `navi ... <url>` or supply the selection to the widget
  2. Check the keybinding/config invoking the opener to ensure it forwards the argument
  3. Quote arguments in shell so they aren't dropped when empty
  4. Wrap the call to handle the Result instead of letting it bubble up

Example fix

// before
url::open(vec![])?; // Error: No URL specified
// after
let args: Vec<String> = std::env::args().skip(1).collect();
if args.is_empty() { eprintln!("usage: open <url>"); return Ok(()); }
url::open(args)?;
Defensive patterns

Strategy: validation

Validate before calling

fn open_url(args: &[String]) -> anyhow::Result<()> {
    if args.is_empty() {
        anyhow::bail!("usage: open <url>");
    }
    navi::common::url::open(args.to_vec())
}

Try / catch

match url::open(args) {
    Ok(()) => {},
    Err(e) if e.to_string() == "No URL specified" => {
        eprintln!("no URL argument provided; check your keybinding/config forwards the selection");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `url::open(vec![])` or any caller passing an empty args list — the command/alias that should carry the URL argument provided none.

Common situations: Invoking navi's URL-opening command/widget without selecting text or supplying an argument, keybinding wired to the wrong command, or shell quoting dropping an empty argument.

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.


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