{"record":{"id":"c1ffb370969ea9b3","repo":"python/cpython","slug":"terminal-doesn-t-have-the-required-cap-capabilit","errorCode":null,"errorMessage":"terminal doesn't have the required {cap} capability","messagePattern":"terminal doesn't have the required (.+?) capability","errorType":"console","errorClass":"InvalidTerminal","httpStatus":null,"severity":"error","filePath":"Lib/_pyrepl/unix_console.py","lineNumber":238,"sourceCode":"        )\n\n        try:\n            self.__input_fd_set(tcgetattr(self.input_fd), ignore=frozenset())\n        except _error as e:\n            raise RuntimeError(f\"termios failure ({e.args[1]})\")\n\n        @overload\n        def _my_getstr(\n            cap: str, optional: Literal[False] = False\n        ) -> bytes: ...\n\n        @overload\n        def _my_getstr(cap: str, optional: bool) -> bytes | None: ...\n\n        def _my_getstr(cap: str, optional: bool = False) -> bytes | None:\n            r = self.terminfo.get(cap)\n            if not optional and r is None:\n                raise InvalidTerminal(\n                    f\"terminal doesn't have the required {cap} capability\"\n                )\n            return r\n\n        self._bel = _my_getstr(\"bel\")\n        self._civis = _my_getstr(\"civis\", optional=True)\n        self._clear = _my_getstr(\"clear\")\n        self._cnorm = _my_getstr(\"cnorm\", optional=True)\n        self._cub = _my_getstr(\"cub\", optional=True)\n        self._cub1 = _my_getstr(\"cub1\", optional=True)\n        self._cud = _my_getstr(\"cud\", optional=True)\n        self._cud1 = _my_getstr(\"cud1\", optional=True)\n        self._cuf = _my_getstr(\"cuf\", optional=True)\n        self._cuf1 = _my_getstr(\"cuf1\", optional=True)\n        self._cup = _my_getstr(\"cup\")\n        self._cuu = _my_getstr(\"cuu\", optional=True)\n        self._cuu1 = _my_getstr(\"cuu1\", optional=True)\n        self._dch1 = _my_getstr(\"dch1\", optional=True)","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/_pyrepl/unix_console.py#L220-L256","documentation":"InvalidTerminal exception from the _my_getstr helper inside UnixConsole.__init__ (Lib/_pyrepl/unix_console.py). Required terminfo string capabilities (bel, clear, and other non-optional caps) must exist in the loaded terminfo entry for the current TERM; if terminfo.TermInfo.get(cap) returns None for a required cap, the console refuses to start with this message naming the missing capability.","triggerScenarios":"Starting pyrepl/UnixConsole with TERM set to a minimal or broken entry — e.g. TERM=dumb, TERM=unknown, a stripped-down terminfo database, or TERM values with no 'bel'/'clear' strings (some printer/legacy entries). Optional caps are fetched with optional=True and don't raise; the non-optional list does.","commonSituations":"SSH into embedded/minimal containers with a truncated /usr/share/terminfo; TERM inherited from a GUI terminal not present on the remote host (e.g. alacritty on an old server); CI runners with TERM unset defaulting to dumb; custom TERMCAP overrides missing required strings.","solutions":["Set TERM to a full-featured entry present on the machine: TERM=xterm (or xterm-256color) and retry.","Install/repair the terminfo database (ncurses-base/terminfo package on Debian/Ubuntu) or copy the missing entry with infocmp/tic from a working host.","If the terminal genuinely lacks the cap, pyrepl cannot run on it — use PYTHON_BASIC_REPL=1 or TERM=xterm emulation."],"exampleFix":"# before\n# TERM=dumb python   -> InvalidTerminal: terminal doesn't have the required bel capability\n\n# after\n# TERM=xterm python","handlingStrategy":"fallback","validationCode":"import shutil, os\n\ndef terminfo_ok():\n    term = os.environ.get('TERM', '')\n    return term not in {'', 'dumb', 'unknown'} and bool(shutil.which('infocmp'))","typeGuard":null,"tryCatchPattern":"try:\n    start_repl()\nexcept InvalidTerminal as e:\n    os.environ['TERM'] = 'xterm'\n    start_repl()  # retry with a capable entry","preventionTips":["Run with TERM=xterm/xterm-256color in containers and CI.","Install terminfo/ncurses-base in minimal images; copy entries with infocmp | tic.","Guard interactive startup with sys.stdin.isatty() and TERM checks."],"tags":["python","pyrepl","terminfo","terminal","environment"],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}