kovidgoyal/kitty · error

Could not get size of controlling terminal with error: %w

Error message

Could not get size of controlling terminal with error: %w

What it means

After opening the controlling terminal, the kitten's GetSize ioctl (querying rows/cols) failed, so it cannot determine the screen width in cells needed to lay out its width tests.

Source

Thrown at tools/cli/wcswidth_kitten.go:226

		test := test_struct{num: len(tests) + 1, description: desc, payload: buf.String(), expected_cursor_positions: expected_cursor_positions}
		tests = append(tests, &test)
	}
	test := test_struct{
		num: len(tests) + 1, description: "Check that combining characters are merged into last cell even when cursor is on the next line",
		payload_gen: wrap_gen, tester: wrap_tester}
	tests = append(tests, &test)
	return
}

func main(allowed_tests *utils.Set[int]) (rc int, err error) {
	term, err := tty.OpenControllingTerm()
	if err != nil {
		return 1, fmt.Errorf("Could not open controlling terminal with error: %w", err)
	}
	sz, err := term.GetSize()
	term.Close()
	if err != nil {
		return 1, fmt.Errorf("Could not get size of controlling terminal with error: %w", err)
	}
	width_in_cells := int(sz.Col)
	if gb_tests, err := kitty.LoadGraphemeBreakTests(); err == nil {
		tests := create_tests(gb_tests, width_in_cells)
		if allowed_tests.Len() > 0 {
			temp := make([]*test_struct, 0, len(tests))
			for _, t := range tests {
				if allowed_tests.Has(t.num) {
					temp = append(temp, t)
				}
			}
			tests = temp
		}
		if err = run_tests(tests); err != nil {
			return 1, err
		}
	} else {
		return 1, err

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Retry from a normal interactive terminal session
  2. Ensure the terminal window is open and not being destroyed during the run
  3. If in a container/sandbox, grant access to a real pty
  4. Update kitty
Defensive patterns

Strategy: try-catch

Try / catch

if rc, err := main(allowed); err != nil { fmt.Fprintln(os.Stderr, err); os.Exit(rc) }

Prevention

When it happens

Trigger: term.GetSize() failing: the tty was closed between open and ioctl, or the underlying TIOCGWINSZ ioctl returns an error on this fd.

Common situations: Terminal closed/resized away mid-invocation, unusual pty implementations, running under minimal containers or sandbox environments where ioctls on the tty are blocked.

Related errors


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