kovidgoyal/kitty · warning

Invalid cached window size, ignoring

Error message

Invalid cached window size, ignoring

What it means

kitty caches the last OS window size to restore geometry on restart; if the cached value is corrupt or unparseable (e.g. truncated cache file or changed format), initial_window_size_func logs this and falls back to computing the size from config.

Source

Thrown at kitty/os_window_size.py:64

    padding: float = getattr(opts.single_window_padding_width, which)
    if padding < 0:
        padding = getattr(opts.window_padding_width, which)
    return float(padding + margin)


def initial_window_size_func(opts: WindowSizeData, cached_values: dict[str, Any]) -> Callable[[int, int, float, float, float, float], tuple[int, int]]:

    if 'window-size' in cached_values and opts.remember_window_size:
        ws = cached_values['window-size']
        try:
            w, h = map(sanitize_window_size, ws)

            def initial_window_size(*a: Any) -> tuple[int, int]:
                return w, h

            return initial_window_size
        except Exception:
            log_error('Invalid cached window size, ignoring')

    w, w_unit = opts.initial_window_sizes.width
    h, h_unit = opts.initial_window_sizes.height

    def get_window_size(cell_width: int, cell_height: int, dpi_x: float, dpi_y: float, xscale: float, yscale: float) -> tuple[int, int]:
        if not is_macos and not is_wayland():
            # Not sure what the deal with scaling on X11 is
            xscale = yscale = 1

        def effective_margin(which: EdgeLiteral) -> float:
            ans: float = getattr(opts.single_window_margin_width, which)
            if ans < 0:
                ans = getattr(opts.window_margin_width, which)
            return ans

        def effective_padding(which: EdgeLiteral) -> float:
            ans: float = getattr(opts.single_window_padding_width, which)
            if ans < 0:

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Ignore it: kitty automatically falls back to config-based sizing
  2. Delete kitty's cache dir (e.g. ~/.cache/kitty) so the size cache is regenerated
  3. If persistent, check initial_window_width/height and remember_window_size settings
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: The window size cache file exists but raises any Exception while being parsed inside initial_window_size_func; called from add_os_window/add_os_panel/_run_app at startup or when opening a new window.

Common situations: Corrupted cache after a crash, kitty upgrade changing the cache format, or a read-only/truncated cache directory.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/76618e10e566be9b. Report an issue: GitHub.