{"record":{"id":"badefb8d33122744","repo":"sxyazi/yazi","slug":"failed-to-spawn-chafa-e","errorCode":null,"errorMessage":"failed to spawn chafa: {e}","messagePattern":"failed to spawn chafa: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"yazi-adapter/src/drivers/chafa.rs","lineNumber":40,"sourceCode":"\t\t\t\t\"off\",\n\t\t\t\t\"--probe\",\n\t\t\t\t\"off\",\n\t\t\t\t\"--polite\",\n\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,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-adapter/src/drivers/chafa.rs#L22-L58","documentation":"The Chafa image driver renders images as terminal symbols by spawning the external `chafa` process via tokio::process::Command. If spawn fails — most commonly NotFound because chafa is not installed or not on the PATH yazi inherited — the io error is wrapped as \"failed to spawn chafa: {e}\" and image preview for that file aborts.","triggerScenarios":"Selecting the chafa adaptor (or falling back to it) on a host where the chafa binary is missing, not executable, or unreachable due to a restricted PATH; spawn can also fail under resource exhaustion (fork/EAGAIN).","commonSituations":"Fresh systems without chafa installed; SSH sessions with minimal PATH; snap/flatpak-installed chafa not visible on PATH; themes/configs expecting symbol-based previews.","solutions":["Install chafa (e.g. `sudo apt install chafa` / `brew install chafa`) and confirm `chafa --version` runs in the same shell that launches yazi","Verify PATH from inside yazi (e.g. `:sh which chafa`) and launch yazi from an environment whose PATH includes the binary","If chafa cannot be provided, rely on a different image adaptor for that terminal"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before rendering with the chafa driver:\nif which::which(\"chafa\").is_err() {\n    bail!(\"chafa is not installed or not on PATH; install it or use another adaptor\");\n}","typeGuard":null,"tryCatchPattern":"match Chafa::image_show(path, area).await {\n    Ok(rect) => { /* render */ }\n    Err(e) if e.to_string().contains(\"failed to spawn chafa\") => { /* fall back to another adaptor / placeholder */ }\n    Err(e) => return Err(e),\n}","preventionTips":["Install chafa on machines that will preview images","Verify PATH inside the exact terminal that launches yazi","Smoke-test with `chafa --version` before enabling symbol previews"],"tags":["chafa","image-preview","process","environment","path"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}