sxyazi/yazi · error

at least one layout ratio must be non-zero: {:?}

Error message

at least one layout ratio must be non-zero: {:?}

What it means

A serde validation guard (TryFrom<[u16; 3]> for MgrRatio) that runs when the `[mgr] ratio` option is deserialized from yazi.toml. It fires when all three layout ratios (parent/current/preview) are 0, which would make column-width division impossible. The input at fault is the user's ratio array, e.g. `ratio = [0, 0, 0]`; at least one value must be a positive integer.

Source

Thrown at yazi-config/src/mgr/ratio.rs:18

use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(try_from = "[u16; 3]")]
pub struct MgrRatio {
	parent:  u16,
	current: u16,
	preview: u16,
}

impl TryFrom<[u16; 3]> for MgrRatio {
	type Error = anyhow::Error;

	fn try_from(ratio: [u16; 3]) -> Result<Self, Self::Error> {
		if ratio.iter().all(|&r| r == 0) {
			bail!("at least one layout ratio must be non-zero: {:?}", ratio);
		}

		Ok(Self { parent: ratio[0], current: ratio[1], preview: ratio[2] })
	}
}

impl TryFrom<Table> for MgrRatio {
	type Error = mlua::Error;

	fn try_from(t: Table) -> Result<Self, Self::Error> {
		Ok([t.raw_get(1)?, t.raw_get(2)?, t.raw_get(3)?].try_into()?)
	}
}

impl FromLua for MgrRatio {
	fn from_lua(value: Value, _: &Lua) -> mlua::Result<Self> {
		match value {
			Value::Table(t) => t.try_into(),

View on GitHub (pinned to 8ebf930f17)

Solutions

  1. Set at least one of the three `[mgr] ratio` entries to a positive number.
  2. Prefer the documented default `[1, 2, 3]` rather than all zeros.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at yazi-config/src/mgr/ratio.rs:23 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sxyazi/yazi@8ebf930f17 (2026-09-09). Data as JSON: /api/errors/9e1f69d86e30d375. Report an issue: GitHub.