kovidgoyal/kitty · warning
Failed to seek in disk cache file
Error message
Failed to seek in disk cache file
What it means
write_dirty_entry computes the write offset as end_of_data_offset for a new cache entry and finds it negative, which should be impossible for a valid open cache file — perror then prints whatever errno happens to hold. It's an internal invariant failure in the disk-cache writer thread; the dirty entry is not persisted.
Source
Thrown at kitty/disk-cache.c:454
find_hole_to_use(self, self->currently_writing.val.data_sz);
return true;
}
s->written_to_disk = true;
s->pos_in_cache_file = 0;
s->data_sz = 0;
}
}
return false;
}
static bool
write_dirty_entry(DiskCache *self) {
size_t left = self->currently_writing.val.data_sz;
uint8_t *p = self->currently_writing.val.data;
if (self->currently_writing.val.pos_in_cache_file < 0) {
self->currently_writing.val.pos_in_cache_file = self->end_of_data_offset;
if (self->currently_writing.val.pos_in_cache_file < 0) {
perror("Failed to seek in disk cache file");
return false;
}
}
off_t offset = self->currently_writing.val.pos_in_cache_file;
while (left > 0) {
ssize_t n = pwrite(self->cache_file_fd, p, left, offset);
if (n < 0) {
if (errno == EINTR || errno == EAGAIN) continue;
perror("Failed to write to disk-cache file");
self->currently_writing.val.pos_in_cache_file = -1;
return false;
}
if (n == 0) {
fprintf(stderr, "Failed to write to disk-cache file with zero return\n");
self->currently_writing.val.pos_in_cache_file = -1;
return false;
}
left -= n;View on GitHub (pinned to 6d5d0c4406)
Solutions
- Quit kitty and delete the disk cache directory so it is recreated cleanly.
- Ensure nothing (cleanup scripts, tmp cleaners like systemd-tmpfiles) deletes kitty cache files while kitty runs.
- Update kitty — writer-thread offset handling has seen fixes.
Defensive patterns
Strategy: fallback
Prevention
- Never delete or truncate kitty's cache files while kitty runs.
- Exclude kitty cache dirs from tmp cleaners (systemd-tmpfiles, bleachbit).
When it happens
Trigger: The cache file fd's size query failed earlier (fstat/lseek returned -1) so end_of_data_offset stayed -1; happens on the background write_loop thread when flushing scrollback to a cache file that was closed, truncated externally, or never sized correctly.
Common situations: External deletion/truncation of kitty's cache file while kitty runs; a corrupted cache after a crash; racing close of the cache during shutdown.
Related errors
- Failed to open second file for defrag of disk cache
- Failed to allocate space for new disk cache file during defr
- Failed to copy data to new disk cache file during defrag
- Failed to write to disk-cache file
- This must be run as kitten ask
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/19616b0366ca2bcc.
Report an issue: GitHub.