sxyazi/yazi · error

Shared memory is not supported by the terminal

Error message

Shared memory is not supported by the terminal

What it means

This is a sentinel guard inside `output_shm`: the shared-memory fast path was attempted even though the terminal never advertised the Kitty shared-memory capability (`EMULATOR.kgp_shm` is false). The caller `output` immediately catches this and falls back to base64 encoding, so the error is control flow rather than a real failure.

Source

Thrown at yazi-adapter/src/drivers/kgp.rs:359

			for y in area.top()..area.bottom() {
				write!(w, "{}", MoveTo(area.x, y))?;
				write!(w, "{s}")?;
			}

			write!(w, "{ResetAttrs}{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?;
			Ok(())
		})
	}

	async fn encode(img: DynamicImage) -> Result<KgpPayload> {
		fn output(raw: &[u8], format: u8, size: (u32, u32)) -> Result<KgpPayload> {
			output_shm(raw, format, size).or_else(|_| output_b64(raw, format, size))
		}

		fn output_shm(raw: &[u8], format: u8, (w, h): (u32, u32)) -> Result<KgpPayload> {
			if !EMULATOR.kgp_shm.get() {
				bail!("Shared memory is not supported by the terminal")
			}

			let mut pl = KgpPayload::with(200, NamedSharedMemory::new(raw)?);
			write!(
				pl,
				"{START}_Gq=2,a=T,C=1,U=1,t=s,f={format},s={w},v={h},i={},S={};{}{ESCAPE}\\{CLOSE}",
				kgp_id(),
				raw.len(),
				pl.name(),
			)?;

			Ok(pl)
		}

		fn output_b64(raw: &[u8], format: u8, (w, h): (u32, u32)) -> Result<KgpPayload> {
			let b64 = general_purpose::STANDARD.encode(raw).into_bytes();
			let mut it = b64.chunks(4096).peekable();
			let mut pl = KgpPayload::new(b64.len() + it.len() * 50);

View on GitHub (pinned to 5f901b886b)

Solutions

  1. No user action needed: the KGP encoder falls back to `output_b64` automatically.
  2. To use shared memory, run a terminal that advertises the Kitty graphic-protocol shared-memory extension.
  3. Ensure terminal capability detection ran correctly at startup so `kgp_shm` reflects the real terminal.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at yazi-adapter/src/drivers/kgp.rs:359 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/05cd633846a37450. Report an issue: GitHub.