sxyazi/yazi · error

invalid 'in' in SearchOpt

Error message

invalid 'in' in SearchOpt

What it means

SearchOpt's TryFrom (yazi-core/src/mgr/search.rs:27) accepts an optional `in` URL, but if present it must be an absolute URL and not itself a search URL. A relative URL or a URL produced by a previous search violates the invariant, so the conversion bails.

Source

Thrown at yazi-core/src/mgr/search.rs:27

#[derive(Clone, Debug)]
pub struct SearchOpt {
	pub via:     SearchVia,
	pub subject: SStr,
	pub args:    Vec<String>,
	pub r#in:    Option<UrlBuf>,
}

impl_data_any!(SearchOpt);

impl TryFrom<ActionCow> for SearchOpt {
	type Error = anyhow::Error;

	fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
		let r#in = a.take::<UrlBuf>("in").ok();
		if let Some(u) = &r#in
			&& (!u.is_absolute() || u.is_search())
		{
			bail!("invalid 'in' in SearchOpt");
		}

		let Ok(args) = yazi_shared::shell::unix::split(a.str("args"), false) else {
			bail!("invalid 'args' in SearchOpt");
		};

		Ok(Self {
			via: a.str("via").parse()?,
			subject: a.take_first().unwrap_or_default(),
			args: args.0,
			r#in,
		})
	}
}

// --- Via
#[derive(Clone, Copy, Debug, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq)]
#[serde(rename_all = "kebab-case")]

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Pass an absolute, non-search URL for `in`, e.g. resolve it against the current tab's cwd with `Url::from_absolute_path` or use `tab.cwd()`.
  2. Expand `~` and relative segments to an absolute path before constructing the action.
  3. Drop the `in` argument entirely to let the search default to the current directory.

Example fix

// before
{ run = "search rg; --in=.'" }
// after
{ run = "search rg;" }  // or supply an absolute path: --in=/home/user/project
Defensive patterns

Strategy: validation

Validate before calling

fn valid_search_root(u: Option<&Url>) -> bool {
    match u {
        None => true,
        Some(u) => u.is_absolute() && !u.is_search(),
    }
}

Prevention

When it happens

Trigger: Passing `in` as a relative path (not absolute) or as a search-kind URL (`u.is_search()`), e.g. reusing the current search result URL as the search root.

Common situations: Plugin or keymap code passing the current directory as a relative string (`.` or `~/...` unexpanded), or chaining searches where the target is a prior search URL instead of a real directory.

Related errors


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/1db2c9f6926174a6. Report an issue: GitHub.