sxyazi/yazi · error
failed to spawn chafa
Error message
failed to spawn chafa: {e} What it means
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.
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.
Example fix
// before (yazi.toml) [plugin] # previewers relying on chafa without it installed // after sudo apt install chafa # or configure a different adapter
Defensive patterns
Strategy: fallback
Validate before calling
-- shell check before relying on chafa previews
if vim.fn.executable("chafa") == 0 then
-- configure a different adapter or disable image previews
end Try / catch
-- Lua adapter wrapper
local ok, out = pcall(function() return adapter:show(url, area) end)
if not ok and tostring(out):find("failed to spawn chafa") then
fallback_to_ueberzug_or_kitty()
end Prevention
- 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.
When it happens
Trigger: Command::new("chafa").spawn() returns Err — chafa is not installed, not on PATH, lacks execute permission, or resource limits prevent forking.
Common situations: chafa not installed on the system; PATH missing the install prefix in the environment yazi runs in; minimal container images without the dependency.
Related errors
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/badefb8d33122744.
Report an issue: GitHub.
Appendix: source
Thrown at yazi-adapter/src/drivers/chafa.rs:40
"off",
"--probe",
"off",
"--polite",
"on",
"--passthrough",
"none",
"--animate",
"off",
"--view-size",
])
.arg(format!("{}x{}", max.width, max.height))
.arg(path)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.kill_on_drop(true)
.spawn()
.map_err(|e| anyhow!("failed to spawn chafa: {e}"))?;
let output = child.wait_with_output().await?;
if !output.status.success() {
bail!("chafa failed with status: {}", output.status);
} else if output.stdout.is_empty() {
bail!("chafa returned no output");
}
let lines: Vec<_> = output.stdout.split(|&b| b == b'\n').collect();
let Ok(Some(first)) = lines[0].to_text().map(|mut t| t.lines.pop()) else {
bail!("failed to parse chafa output");
};
let area = Rect {
x: max.x,
y: max.y,
width: first.width() as u16,
height: lines.len() as u16,View on GitHub (pinned to 5f901b886b)