kovidgoyal/kitty · error
Failed to create a temp file for image data transmission: %w
Error message
Failed to create a temp file for image data transmission: %w
What it means
For in-memory frames sent by file transmission, icat writes the bytes to a RAM-backed temp file (images.CreateTempInRAM); creating that temp file failed.
Source
Thrown at kittens/icat/transmit.go:137
err = gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(mmap.Name()))
return
}
func transmit_file(imgd *image_data, frame_num int, frame *image_frame) (err error) {
is_temp := false
fname := ""
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))
}
View on GitHub (pinned to 6d5d0c4406)
Solutions
- Free space in the tmpfs/TMPDIR used for temp files or enlarge it
- Set TMPDIR to a location with adequate space
- Reduce image sizes; close other processes hogging fds/space
Example fix
# before docker run ... kitten icat big.png # after docker run -e TMPDIR=/var/tmp ... kitten icat big.png
Defensive patterns
Strategy: fallback
Validate before calling
var s syscall.Statfs_t
syscall.Statfs(os.TempDir(), &s)
if s.Bavail*uint64(s.Bsize) < uint64(imgSize) { /* free space or set bigger TMPDIR */ } Try / catch
if err != nil && strings.Contains(err.Error(), "temp file") { /* free tmpfs or point TMPDIR elsewhere and retry */ } Prevention
- Keep TMPDIR/tmpfs with free space for large images
- Set TMPDIR to a roomy local directory in containers
When it happens
Trigger: CreateTempInRAM failing — tmpfs (e.g. /dev/shm or TMPDIR pointing at tmpfs) full or unwritable, or too many temp files.
Common situations: Small /dev/shm in containers with large images; TMPDIR set to a full/unwritable location; file-descriptor exhaustion.
Related errors
- Failed to write image data to temp file for transmission: %w
- Timed out waiting for a response from the terminal: %w
- Invalid value for --background: %w
- Invalid value for --z-index with error: %w
- unknown fit specification: %#v
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/dbc9ece1decc5735.
Report an issue: GitHub.