kovidgoyal/kitty · error
Failed to read from session file, ignoring: {default_session
Error message
Failed to read from session file, ignoring: {default_session} What it means
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).
Source
Thrown at kitty/session.py:352
session_path = args.session.session_path
else:
if args.session == '-':
f = sys.stdin
else:
f = open(resolve_custom_file(args.session))
with f:
session_data = f.read()
session_path = f.name
yield from parse_session(session_data, opts, environ=environ, session_arg=session_arg, session_path=session_path)
return
if default_session and default_session != 'none' and not getattr(args, 'args', None):
session_arg = session_arg_to_name(default_session)
try:
with open(default_session) as f:
session_data = f.read()
session_path = f.name
except OSError:
log_error(f'Failed to read from session file, ignoring: {default_session}')
else:
yield from parse_session(session_data, opts, session_arg=session_arg, session_path=session_path)
return
ans = Session()
current_layout = opts.enabled_layouts[0] if opts.enabled_layouts else 'tall'
ans.add_tab(opts)
ans.tabs[-1].layout = current_layout
if args is not None:
ans.os_window_class = args.cls
ans.os_window_name = args.name
ans.os_window_title = args.title
if special_window is None:
cmd = args.args if args and args.args else resolved_shell(opts)
from kitty.tabs import SpecialWindow
cwd: str | None = args.directory if respect_cwd and args else None
special_window = SpecialWindow(cmd, cwd_from=cwd_from, cwd=cwd, env=env_when_no_session, hold=bool(args and args.hold))
ans.add_special_window(special_window)View on GitHub (pinned to 6d5d0c4406)
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
Example fix
# before (relative, wrong dir) session startup.session # after session /home/user/.config/kitty/startup.session
Defensive patterns
Strategy: validation
Validate before calling
import os
p = '/abs/path/to/session.file'
assert os.path.isfile(p) and os.access(p, os.R_OK), f'bad session file: {p}' Type guard
def is_readable_session(path: str) -> bool:
import os
return os.path.isfile(path) and os.access(path, os.R_OK) Prevention
- Use absolute paths for session files in kitty.conf
- Remember kitty resolves relative paths against its config dir, not $PWD
When it happens
Trigger: open(default_session) raises OSError — file missing, unreadable permissions, or a directory — inside create_sessions.
Common situations: Relative path resolved differently than expected (session paths in kitty.conf are relative to config dir), moved/renamed file, or permission issues.
Related errors
- This should be run as kitten broadcast
- No option named: {k}
- No custom kitten named {kitten} found
- Not a number: {x} with error: {e}
- Not a valid unit: {x}. Allowed units are: {default_unit}, {"
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/5267bb98e3b1e598.
Report an issue: GitHub.