{"record":{"id":"5267bb98e3b1e598","repo":"kovidgoyal/kitty","slug":"failed-to-read-from-session-file-ignoring-defau","errorCode":null,"errorMessage":"Failed to read from session file, ignoring: {default_session}","messagePattern":"Failed to read from session file, ignoring: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/session.py","lineNumber":352,"sourceCode":"                session_path = args.session.session_path\n            else:\n                if args.session == '-':\n                    f = sys.stdin\n                else:\n                    f = open(resolve_custom_file(args.session))\n                with f:\n                    session_data = f.read()\n                    session_path = f.name\n            yield from parse_session(session_data, opts, environ=environ, session_arg=session_arg, session_path=session_path)\n            return\n    if default_session and default_session != 'none' and not getattr(args, 'args', None):\n        session_arg = session_arg_to_name(default_session)\n        try:\n            with open(default_session) as f:\n                session_data = f.read()\n                session_path = f.name\n        except OSError:\n            log_error(f'Failed to read from session file, ignoring: {default_session}')\n        else:\n            yield from parse_session(session_data, opts, session_arg=session_arg, session_path=session_path)\n            return\n    ans = Session()\n    current_layout = opts.enabled_layouts[0] if opts.enabled_layouts else 'tall'\n    ans.add_tab(opts)\n    ans.tabs[-1].layout = current_layout\n    if args is not None:\n        ans.os_window_class = args.cls\n        ans.os_window_name = args.name\n        ans.os_window_title = args.title\n    if special_window is None:\n        cmd = args.args if args and args.args else resolved_shell(opts)\n        from kitty.tabs import SpecialWindow\n\n        cwd: str | None = args.directory if respect_cwd and args else None\n        special_window = SpecialWindow(cmd, cwd_from=cwd_from, cwd=cwd, env=env_when_no_session, hold=bool(args and args.hold))\n    ans.add_special_window(special_window)","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/session.py#L334-L370","documentation":"kitty could not open/read the configured session file (default_session or --session argument). It logs and falls back to an empty default session (one tab, first enabled layout).","triggerScenarios":"open(default_session) raises OSError — file missing, unreadable permissions, or a directory — inside create_sessions.","commonSituations":"Relative path resolved differently than expected (session paths in kitty.conf are relative to config dir), moved/renamed file, or permission issues.","solutions":["Use an absolute path for the session file in kitty.conf","If relative, place it in the kitty config directory where kitty resolves relative paths","Verify with: test -r /path/to/session.file && kitty --session /path/to/session.file"],"exampleFix":"# before (relative, wrong dir)\nsession startup.session\n\n# after\nsession /home/user/.config/kitty/startup.session","handlingStrategy":"validation","validationCode":"import os\np = '/abs/path/to/session.file'\nassert os.path.isfile(p) and os.access(p, os.R_OK), f'bad session file: {p}'","typeGuard":"def is_readable_session(path: str) -> bool:\n    import os\n    return os.path.isfile(path) and os.access(path, os.R_OK)","tryCatchPattern":null,"preventionTips":["Use absolute paths for session files in kitty.conf","Remember kitty resolves relative paths against its config dir, not $PWD"],"tags":["kitty","session-file","config","file-io"],"backgroundTag":"config-file-not-found","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}