{"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":null,"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/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-adapter/src/drivers/chafa.rs#L22-L58","documentation":"The chafa image adapter renders images by spawning the external `chafa` binary. If the spawn itself fails (binary not found, not executable, fork/exec error), the io::Error is wrapped with anyhow! into \"failed to spawn chafa: {e}\". The underlying OS error is included in the message.","triggerScenarios":"Command::new(\"chafa\").spawn() returns Err — chafa is not installed, not on PATH, lacks execute permission, or resource limits prevent forking.","commonSituations":"chafa not installed on the system; PATH missing the install prefix in the environment yazi runs in; minimal container images without the dependency.","solutions":["Install chafa (e.g. `apt install chafa`, `brew install chafa`) or pick another image adapter in yazi.toml.","Verify `chafa` is runnable: `which chafa && chafa --version`.","Check PATH inside the environment yazi was launched from, especially in GUI-launched sessions."],"exampleFix":"// before (yazi.toml)\n[plugin]\n# previewers relying on chafa without it installed\n// after\nsudo apt install chafa  # or configure a different adapter","handlingStrategy":"fallback","validationCode":"-- shell check before relying on chafa previews\nif vim.fn.executable(\"chafa\") == 0 then\n  -- configure a different adapter or disable image previews\nend","typeGuard":null,"tryCatchPattern":"-- Lua adapter wrapper\nlocal ok, out = pcall(function() return adapter:show(url, area) end)\nif not ok and tostring(out):find(\"failed to spawn chafa\") then\n  fallback_to_ueberzug_or_kitty()\nend","preventionTips":["Install chafa and confirm it is on PATH of the session running yazi.","Configure an image adapter that matches the actually installed tools.","In containers/CI, disable image previews or install dependencies explicitly."],"tags":["external-binary","image-preview","spawn"],"backgroundTag":"command-not-found","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}