sxyazi/yazi · error

chafa returned no output

Error message

chafa returned no output

What it means

The chafa process exited successfully (status 0) but wrote zero bytes to stdout, so there is no graphic to pass through to the terminal. Since stderr is piped to null and animation is off, this typically means chafa silently produced nothing for the given image path or view size rather than reporting an error.

Source

Thrown at yazi-adapter/src/drivers/chafa.rs:46

				"none",
				"--animate",
				"off",
				"--view-size",
			])
			.arg(format!("{}x{}", max.width, max.height))
			.arg(path)
			.stdin(Stdio::null())
			.stdout(Stdio::piped())
			.stderr(Stdio::null())
			.kill_on_drop(true)
			.spawn()
			.map_err(|e| anyhow!("failed to spawn chafa: {e}"))?;

		let output = child.wait_with_output().await?;
		if !output.status.success() {
			bail!("chafa failed with status: {}", output.status);
		} else if output.stdout.is_empty() {
			bail!("chafa returned no output");
		}

		let lines: Vec<_> = output.stdout.split(|&b| b == b'\n').collect();
		let Ok(Some(first)) = lines[0].to_text().map(|mut t| t.lines.pop()) else {
			bail!("failed to parse chafa output");
		};

		let area = Rect {
			x:      max.x,
			y:      max.y,
			width:  first.width() as u16,
			height: lines.len() as u16,
		};

		ADAPTOR.image_hide()?;
		ADAPTOR.shown_store(area);
		Emulator::move_lock((max.x, max.y), |w| {
			for (i, line) in lines.into_iter().enumerate() {

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Verify the image file at `path` is a valid, non-empty image that chafa can decode.
  2. Ensure the `--view-size` dimensions passed (`max.width x max.height`) are non-zero and sane.
  3. Run chafa manually on the same file and arguments to see what it reports on stderr, which the code discards.
  4. Fall back to another image preview adapter or skip the preview when chafa yields no output.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at yazi-adapter/src/drivers/chafa.rs:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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