kovidgoyal/kitty · error
Failed to write image data to temp file for transmission: %w
Error message
Failed to write image data to temp file for transmission: %w
What it means
Raised by transmit_file in the icat kitten when image data held in memory cannot be written to a temporary file before being transmitted to the terminal. The temp file is used when the image frame exists only as in-memory bytes rather than a file on disk. The error wraps the underlying os write failure.
Source
Thrown at kittens/icat/transmit.go:144
var data_size int
if frame.in_memory_bytes == nil {
fname, err = filepath.Abs(frame.filename)
if err != nil {
return fmt.Errorf("Failed to convert image data output file: %s to absolute path with error: %w", frame.filename, err)
}
frame.filename = "" // so it isn't deleted in cleanup
} else {
is_temp = true
f, err := images.CreateTempInRAM()
if err != nil {
return fmt.Errorf("Failed to create a temp file for image data transmission: %w", err)
}
data_size = len(frame.in_memory_bytes)
_, err = bytes.NewBuffer(frame.in_memory_bytes).WriteTo(f)
f.Close()
if err != nil {
os.Remove(f.Name())
return fmt.Errorf("Failed to write image data to temp file for transmission: %w", err)
}
fname = f.Name()
}
gc := gc_for_image(imgd, frame_num, frame)
gc.SetTransmission(utils.IfElse(is_temp, graphics.GRT_transmission_tempfile, graphics.GRT_transmission_file))
if data_size > 0 {
gc.SetDataSize(uint64(data_size))
}
return gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(fname))
}
func transmit_stream(imgd *image_data, frame_num int, frame *image_frame) (err error) {
data := frame.in_memory_bytes
if data == nil {
data, err = os.ReadFile(frame.filename)
if err != nil {
return fmt.Errorf("Failed to read image data output file: %s with error: %w", frame.filename, err)
}View on GitHub (pinned to 6d5d0c4406)
Solutions
- Check TMPDIR / temp directory writability: echo test > $TMPDIR/x and remove it
- Free disk space or point TMPDIR to a writable location with space
- If running in a container/sandbox, mount a writable /tmp
- Retry after fixing permissions on the temp dir
Example fix
# before TMPDIR=/nonexistent kitty +kitten icat img.png # after mkdir -p /tmp/kitty && TMPDIR=/tmp/kitty kitty +kitten icat img.png
Defensive patterns
Strategy: validation
Validate before calling
import "os"
tmp := os.TempDir()
f, err := os.CreateTemp(tmp, "probe")
if err != nil { /* fail early with a clear message */ }
f.Close(); os.Remove(f.Name()) Prevention
- Keep a writable, spacious TMPDIR
- Monitor disk space on temp filesystems
- In containers mount /tmp writable
When it happens
Trigger: Calling the icat kitten with an image supplied via stdin or an in-memory frame (e.g. from a pipe or processed image) when the temp directory is not writable or the disk is full. bytes.NewBuffer(...).WriteTo(f) fails mid-write.
Common situations: TMPDIR pointing to a nonexistent or read-only directory, disk-full on /tmp, sandboxed/container environments with a read-only temp dir, or permissions issues on the kitty config/temp paths.
Related errors
- Failed to open image data output file: %s with error: %w
- Failed to seek in image data output file: %s with error: %w
- Failed to read data from image output data file: %w
- Failed to convert image data output file: %s to absolute pat
- Failed to create a temp file for image data transmission: %w
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/b003e351f25012ca.
Report an issue: GitHub.