{"record":{"id":"f22bd003246b62c5","repo":"kovidgoyal/kitty","slug":"with-error","errorCode":null,"errorMessage":"with error","messagePattern":"with error","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/launcher/cmdline.c","lineNumber":77,"sourceCode":"    a->buf[a->pos++] = 0;\n    return true;\n}\n\nbool\nget_argv_from(const char *filename, const char *argv0, argv_array *final_ans) {\n    (void)get_config_dir;\n    if (!filename || !filename[0]) return true;\n    size_t src_sz;\n    char *src = read_full_file(filename, &src_sz);\n    if (!src) {\n        if (errno == ENOENT || errno == ENOTDIR) return true;\n#ifdef __APPLE__\n        int saved = errno;\n        os_log_error(OS_LOG_DEFAULT, \"Failed to read from %{public}s with error: %{darwin.errno}d\", filename, errno);\n        errno = saved;\n#endif\n        fprintf(stderr, \"Failed to read from %s \", filename);\n        perror(\"with error\");\n        return true;\n    }\n    ShlexState s = {0};\n    argv_array ans = {0};\n    bool ok = false;\n    ans.buf = malloc(src_sz + strlen(argv0) + 64);\n    if (!ans.buf) goto oom;\n    ans.needs_free = true;\n    if (!add_to_argv(&ans, argv0, strlen(argv0))) goto oom;\n    if (!alloc_shlex_state(&s, src, src_sz, false)) goto oom;\n    bool keep_going = true;\n    while (keep_going) {\n        ssize_t q = next_word(&s);\n        switch (q) {\n            case -1: fprintf(stderr, \"Failed to parse %s with error: %s\\n\", filename, s.err); goto end;\n            case -2: keep_going = false; break;\n            default:\n                if (ans.count == 1 && strcmp(s.buf, \"kitty\") == 0) continue;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/launcher/cmdline.c#L59-L95","documentation":"Emitted by kitty's launcher when it cannot read the file given by --cmd-file / the startup file used to reconstruct argv (e.g. via KITTY_CMD_FILE or the wrapper scripts). perror prints the errno (ENOENT, EACCES, EISDIR...). get_argv_from then returns true with an empty result, so kitty typically falls back to defaults or exits soon after.","triggerScenarios":"kitty launched by a wrapper that passes a command file which doesn't exist, is a directory, or is unreadable — read()/stat on `filename` failed in get_argv_from before shell-lexing it.","commonSituations":"Stale KITTY_CMD_FILE left by a crashed wrapper; kitty.desktop or a script referencing a deleted cmd file; permissions changed after sudo/su; file on an unmounted network share.","solutions":["Check that the file passed as the command file exists and is readable at launch time (cat it manually with the same user).","If using a wrapper script, ensure it writes the cmd file synchronously before exec'ing kitty.","Clear stale KITTY_CMD_FILE from the environment.","Re-run the launcher from a terminal to see the errno string appended after 'with error'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"test -r \"$KITTY_CMD_FILE\" && echo ok || echo missing  # check before launching via wrapper","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write the cmd file synchronously in wrappers before exec kitty.","Unset stale KITTY_CMD_FILE in environments.","Use absolute paths for cmd files."],"tags":["launcher","file-read","kitty"],"backgroundTag":"config-file-unreadable","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}