{"record":{"id":"a058e233e776431f","repo":"kovidgoyal/kitty","slug":"usage-kitty-runpy-some-python-code","errorCode":null,"errorMessage":"Usage: kitty +runpy \"some python code\"","messagePattern":"Usage: kitty \\+runpy \"some python code\"","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"kitty/entry_points.py","lineNumber":23,"sourceCode":"import os\nimport sys\n\n\ndef icat(args: list[str]) -> None:\n    from kitty.constants import kitten_exe\n\n    os.execl(kitten_exe(), 'kitten', *args)\n\n\ndef list_fonts(args: list[str]) -> None:\n    from kitty.fonts.list import main as list_main\n\n    list_main(args)\n\n\ndef runpy(args: list[str]) -> None:\n    if len(args) < 2:\n        raise SystemExit('Usage: kitty +runpy \"some python code\"')\n    sys.argv = ['kitty'] + args[2:]\n    exec(args[1])\n\n\ndef hold(args: list[str]) -> None:\n    from kitty.constants import kitten_exe\n\n    args = ['kitten', '__hold_till_enter__'] + args[1:]\n    os.execvp(kitten_exe(), args)\n\n\ndef complete(args: list[str]) -> None:\n    # Delegate to kitten to maintain backward compatibility\n    if len(args) < 2 or args[1] not in ('setup', 'zsh', 'fish2', 'bash'):\n        raise SystemExit(1)\n    if args[1] == 'fish2':\n        args[1:1] = ['fish', '_legacy_completion=fish2']\n    elif len(args) >= 3 and args[1:3] == ['setup', 'fish2']:","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/entry_points.py#L5-L41","documentation":"The kitty +runpy entry point requires the python code as the first argument; with fewer than 2 args it prints usage and exits via SystemExit.","triggerScenarios":"Running `kitty +runpy` with no python code argument.","commonSituations":"Shell scripts where the code string variable is empty/unset due to quoting mistakes.","solutions":["Pass the code: kitty +runpy \"print(1)\"","Quote the code so it arrives as a single argv element","Check the variable expansion in scripts before invoking"],"exampleFix":"# before\nkitty +runpy\n# after\nkitty +runpy \"import kitty; print(kitty.__version__)\"","handlingStrategy":"validation","validationCode":"import sys\ncode = sys.argv[1] if len(sys.argv) > 1 else None\nif not code:\n    sys.exit('Usage: kitty +runpy \"some python code\"')\nrunpy_entry(['kitty', code])","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote the python code as a single argv element","Guard wrapper scripts against empty code variables"],"tags":["kitty","cli","usage","runpy"],"backgroundTag":"missing-cli-argument","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}