{"record":{"id":"05cd633846a37450","repo":"sxyazi/yazi","slug":"shared-memory-is-not-supported-by-the-terminal","errorCode":null,"errorMessage":"Shared memory is not supported by the terminal","messagePattern":"Shared memory is not supported by the terminal","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-adapter/src/drivers/kgp.rs","lineNumber":359,"sourceCode":"\n\t\t\tfor y in area.top()..area.bottom() {\n\t\t\t\twrite!(w, \"{}\", MoveTo(area.x, y))?;\n\t\t\t\twrite!(w, \"{s}\")?;\n\t\t\t}\n\n\t\t\twrite!(w, \"{ResetAttrs}{START}_Gq=2,a=d,d=A{ESCAPE}\\\\{CLOSE}\")?;\n\t\t\tOk(())\n\t\t})\n\t}\n\n\tasync fn encode(img: DynamicImage) -> Result<KgpPayload> {\n\t\tfn output(raw: &[u8], format: u8, size: (u32, u32)) -> Result<KgpPayload> {\n\t\t\toutput_shm(raw, format, size).or_else(|_| output_b64(raw, format, size))\n\t\t}\n\n\t\tfn output_shm(raw: &[u8], format: u8, (w, h): (u32, u32)) -> Result<KgpPayload> {\n\t\t\tif !EMULATOR.kgp_shm.get() {\n\t\t\t\tbail!(\"Shared memory is not supported by the terminal\")\n\t\t\t}\n\n\t\t\tlet mut pl = KgpPayload::with(200, NamedSharedMemory::new(raw)?);\n\t\t\twrite!(\n\t\t\t\tpl,\n\t\t\t\t\"{START}_Gq=2,a=T,C=1,U=1,t=s,f={format},s={w},v={h},i={},S={};{}{ESCAPE}\\\\{CLOSE}\",\n\t\t\t\tkgp_id(),\n\t\t\t\traw.len(),\n\t\t\t\tpl.name(),\n\t\t\t)?;\n\n\t\t\tOk(pl)\n\t\t}\n\n\t\tfn output_b64(raw: &[u8], format: u8, (w, h): (u32, u32)) -> Result<KgpPayload> {\n\t\t\tlet b64 = general_purpose::STANDARD.encode(raw).into_bytes();\n\t\t\tlet mut it = b64.chunks(4096).peekable();\n\t\t\tlet mut pl = KgpPayload::new(b64.len() + it.len() * 50);","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-adapter/src/drivers/kgp.rs#L341-L377","documentation":"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.","triggerScenarios":"Thrown at yazi-adapter/src/drivers/kgp.rs:359 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No user action needed: the KGP encoder falls back to `output_b64` automatically.","To use shared memory, run a terminal that advertises the Kitty graphic-protocol shared-memory extension.","Ensure terminal capability detection ran correctly at startup so `kgp_shm` reflects the real terminal."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}