{"record":{"id":"c977b4150e83de0e","repo":"RustPython/RustPython","slug":"insufficient-terminal-horizontal","errorCode":null,"errorMessage":"insufficient terminal (horizontal)","messagePattern":"insufficient terminal \\(horizontal\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Lib/_pyrepl/unix_console.py","lineNumber":612,"sourceCode":"\n    def __enable_bracketed_paste(self) -> None:\n        os.write(self.output_fd, b\"\\x1b[?2004h\")\n\n    def __disable_bracketed_paste(self) -> None:\n        os.write(self.output_fd, b\"\\x1b[?2004l\")\n\n    def __setup_movement(self):\n        \"\"\"\n        Set up the movement functions based on the terminal capabilities.\n        \"\"\"\n        if 0 and self._hpa:  # hpa don't work in windows telnet :-(\n            self.__move_x = self.__move_x_hpa\n        elif self._cub and self._cuf:\n            self.__move_x = self.__move_x_cub_cuf\n        elif self._cub1 and self._cuf1:\n            self.__move_x = self.__move_x_cub1_cuf1\n        else:\n            raise RuntimeError(\"insufficient terminal (horizontal)\")\n\n        if self._cuu and self._cud:\n            self.__move_y = self.__move_y_cuu_cud\n        elif self._cuu1 and self._cud1:\n            self.__move_y = self.__move_y_cuu1_cud1\n        else:\n            raise RuntimeError(\"insufficient terminal (vertical)\")\n\n        if self._dch1:\n            self.dch1 = self._dch1\n        elif self._dch:\n            self.dch1 = terminfo.tparm(self._dch, 1)\n        else:\n            self.dch1 = None\n\n        if self._ich1:\n            self.ich1 = self._ich1\n        elif self._ich:","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/RustPython/RustPython/blob/aaeab4f754b4f40efc0c8ab39cf7c4a3c35a8cfd/Lib/_pyrepl/unix_console.py#L594-L630","documentation":"During UnixConsole.__setup_movement, horizontal cursor movement needs one of: hpa (permanently disabled by the `0 and` guard), cub+cuf, or cub1+cuf1. If the terminfo entry provides none of these pairs, RuntimeError('insufficient terminal (horizontal)') stops console init. The terminal description is too minimal to reposition the cursor left/right, which the editor display requires.","triggerScenarios":"TERM=dumb or a synthetic/minimal terminfo entry lacking cursor-movement caps; running the REPL against a stripped entry on a capture pipe or test pty; a corrupt or truncated terminfo database where movement caps are missing.","commonSituations":"Headless test harnesses that fabricate a tiny terminfo entry; embedded devices with hand-rolled termcap; alpine-style images that ship only dumb entries; over-customized TERM entries in restricted environments.","solutions":["Use a complete terminal description: `export TERM=xterm-256color`","Install/repair the terminfo database (ncurses-term / ncurses-terminfo) and confirm with `infocmp $TERM | grep -E 'cub|cuf'`","If you maintain the terminfo entry, add cub1/cuf1 (or cub/cuf) capabilities to it","Catch RuntimeError from console init and degrade to line editing without cursor control"],"exampleFix":"# before\n$ TERM=dumb python -m _pyrepl.simple_interact  # RuntimeError: insufficient terminal (horizontal)\n# after\n$ TERM=xterm python -m _pyrepl.simple_interact","handlingStrategy":"validation","validationCode":"import os, curses\n\ncurses.setupterm(os.environ.get('TERM') or 'xterm')\nhas_h = (curses.tigetstr('cub') and curses.tigetstr('cuf')) or \\\n         (curses.tigetstr('cub1') and curses.tigetstr('cuf1'))\nif not has_h:\n    raise SystemExit('terminal lacks horizontal movement caps (cub/cuf/cub1/cuf1); use TERM=xterm')","typeGuard":null,"tryCatchPattern":"try:\n    console = UnixConsole()\nexcept RuntimeError as e:\n    if 'insufficient terminal' in str(e):\n        raise SystemExit('set TERM to a full entry, e.g. xterm-256color') from e\n    raise","preventionTips":["Never point TERM at dumb/unknown entries when an interactive REPL will run","Smoke-test movement capabilities during environment setup","Keep full ncurses terminfo packages installed on dev and CI images"],"tags":["terminfo","cursor-movement","pyrepl","terminal"],"backgroundTag":"terminfo-missing-capability","analyzedSha":"aaeab4f754b4f40efc0c8ab39cf7c4a3c35a8cfd","analyzedAt":"2026-08-17T00:37:52.100Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}