{"record":{"id":"73403817e8fffc5e","repo":"sxyazi/yazi","slug":"chafa-failed-with-status","errorCode":null,"errorMessage":"chafa failed with status: {}","messagePattern":"chafa failed with status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-adapter/src/drivers/chafa.rs","lineNumber":44,"sourceCode":"\t\t\t\t\"on\",\n\t\t\t\t\"--passthrough\",\n\t\t\t\t\"none\",\n\t\t\t\t\"--animate\",\n\t\t\t\t\"off\",\n\t\t\t\t\"--view-size\",\n\t\t\t])\n\t\t\t.arg(format!(\"{}x{}\", max.width, max.height))\n\t\t\t.arg(path)\n\t\t\t.stdin(Stdio::null())\n\t\t\t.stdout(Stdio::piped())\n\t\t\t.stderr(Stdio::null())\n\t\t\t.kill_on_drop(true)\n\t\t\t.spawn()\n\t\t\t.map_err(|e| anyhow!(\"failed to spawn chafa: {e}\"))?;\n\n\t\tlet output = child.wait_with_output().await?;\n\t\tif !output.status.success() {\n\t\t\tbail!(\"chafa failed with status: {}\", output.status);\n\t\t} else if output.stdout.is_empty() {\n\t\t\tbail!(\"chafa returned no output\");\n\t\t}\n\n\t\tlet lines: Vec<_> = output.stdout.split(|&b| b == b'\\n').collect();\n\t\tlet Ok(Some(first)) = lines[0].to_text().map(|mut t| t.lines.pop()) else {\n\t\t\tbail!(\"failed to parse chafa output\");\n\t\t};\n\n\t\tlet area = Rect {\n\t\t\tx:      max.x,\n\t\t\ty:      max.y,\n\t\t\twidth:  first.width() as u16,\n\t\t\theight: lines.len() as u16,\n\t\t};\n\n\t\tADAPTOR.image_hide()?;\n\t\tADAPTOR.shown_store(area);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-adapter/src/drivers/chafa.rs#L26-L62","documentation":"The chafa preview adapter shells out to the `chafa` binary to render image previews. If the spawned process exits with a non-zero status, the adapter surfaces the exit status as an anyhow error instead of a preview. This is a wrapper around the external tool's failure, not a yazi-internal fault.","triggerScenarios":"`image_show` spawns `chafa` with the image path and options; `wait_with_output()` returns a non-successful `ExitStatus` — e.g. chafa can't read the input file, unsupported format, bad flags, or a chafa version whose CLI changed.","commonSituations":"`chafa` not installed or an old/newer version with different CLI flags; previewing a corrupt or unsupported image file; permission problems on the image path; misconfigured adapter options in yazi's `[preview]` config passed through to chafa.","solutions":["Install or update chafa (`apt install chafa`, `brew install chafa`) and verify `chafa --version` works","Run the exact chafa command manually with the same flags to see chafa's own error message","Check that the image file exists and is readable by the chafa process","Review yazi adapter config for invalid options forwarded to chafa; remove unsupported flags"],"exampleFix":"// before\n# yazi.toml\n[preview]\nimage_filter = \"invalid-flag-value\"  # forwarded to chafa, exits non-zero\n// after\n[preview]\nimage_filter = \"triangle\"  # valid value accepted by chafa","handlingStrategy":"try-catch","validationCode":"use std::process::Command;\nfn chafa_available() -> bool {\n    Command::new(\"chafa\").arg(\"--version\").output()\n        .map(|o| o.status.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match adapter.show(path).await {\n    Err(e) if e.to_string().starts_with(\"chafa failed with status\") => {\n        tracing::warn!(\"image preview unavailable: {e:#}\");\n        fallback_to_text_preview(path).await;\n    }\n    other => other?,\n}","preventionTips":["Verify chafa is on PATH and its version matches the flags yazi sends","Reproduce the chafa invocation manually to read its stderr","Keep yazi and chafa versions in sync after upgrades","Fall back to a text/none previewer when the binary is missing"],"tags":["external-process","image-preview","chafa","cli"],"backgroundTag":"external-command-nonzero-exit","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}