{"record":{"id":"dca3276aafe9a936","repo":"kovidgoyal/kitty","slug":"could-not-get-size-of-controlling-terminal-with-er","errorCode":null,"errorMessage":"Could not get size of controlling terminal with error: %w","messagePattern":"Could not get size of controlling terminal with error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cli/wcswidth_kitten.go","lineNumber":226,"sourceCode":"\t\ttest := test_struct{num: len(tests) + 1, description: desc, payload: buf.String(), expected_cursor_positions: expected_cursor_positions}\n\t\ttests = append(tests, &test)\n\t}\n\ttest := test_struct{\n\t\tnum: len(tests) + 1, description: \"Check that combining characters are merged into last cell even when cursor is on the next line\",\n\t\tpayload_gen: wrap_gen, tester: wrap_tester}\n\ttests = append(tests, &test)\n\treturn\n}\n\nfunc main(allowed_tests *utils.Set[int]) (rc int, err error) {\n\tterm, err := tty.OpenControllingTerm()\n\tif err != nil {\n\t\treturn 1, fmt.Errorf(\"Could not open controlling terminal with error: %w\", err)\n\t}\n\tsz, err := term.GetSize()\n\tterm.Close()\n\tif err != nil {\n\t\treturn 1, fmt.Errorf(\"Could not get size of controlling terminal with error: %w\", err)\n\t}\n\twidth_in_cells := int(sz.Col)\n\tif gb_tests, err := kitty.LoadGraphemeBreakTests(); err == nil {\n\t\ttests := create_tests(gb_tests, width_in_cells)\n\t\tif allowed_tests.Len() > 0 {\n\t\t\ttemp := make([]*test_struct, 0, len(tests))\n\t\t\tfor _, t := range tests {\n\t\t\t\tif allowed_tests.Has(t.num) {\n\t\t\t\t\ttemp = append(temp, t)\n\t\t\t\t}\n\t\t\t}\n\t\t\ttests = temp\n\t\t}\n\t\tif err = run_tests(tests); err != nil {\n\t\t\treturn 1, err\n\t\t}\n\t} else {\n\t\treturn 1, err","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cli/wcswidth_kitten.go#L208-L244","documentation":"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.","triggerScenarios":"term.GetSize() failing: the tty was closed between open and ioctl, or the underlying TIOCGWINSZ ioctl returns an error on this fd.","commonSituations":"Terminal closed/resized away mid-invocation, unusual pty implementations, running under minimal containers or sandbox environments where ioctls on the tty are blocked.","solutions":["Retry from a normal interactive terminal session","Ensure the terminal window is open and not being destroyed during the run","If in a container/sandbox, grant access to a real pty","Update kitty"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if rc, err := main(allowed); err != nil { fmt.Fprintln(os.Stderr, err); os.Exit(rc) }","preventionTips":["Keep the terminal window open during the run","Run in a real terminal, not a minimal container pty"],"tags":["kitty","tty","ioctl","terminal-size"],"backgroundTag":"terminal-size-query-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}