kovidgoyal/kitty · warning

Failed to read cwd of {cwd_from} with error: {err}

Error message

Failed to read cwd of {cwd_from} with error: {err}

What it means

When a child window is launched with `cwd_from` (a running process to inherit the working directory from), kitty calls modify_argv_for_launch_with_cwd and any exception is logged; the child then starts in the fallback cwd.

Source

Thrown at kitty/child.py:356

        is_clone_launch: str = '',
        add_listen_on_env_var: bool = True,
        hold: bool = False,
        pass_fds: tuple[int, ...] = (),
        remote_control_fd: int = -1,
        hold_after_ssh: bool = False,
        startup_command_via_shell_integration: Sequence[str] | str = (),
    ):
        self.is_clone_launch = is_clone_launch
        self.id = next(child_counter)
        self.add_listen_on_env_var = add_listen_on_env_var
        self.argv = list(argv)
        self.pass_fds = pass_fds
        self.remote_control_fd = remote_control_fd
        if cwd_from:
            try:
                cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv, env, hold_after_ssh=hold_after_ssh) or cwd
            except Exception as err:
                log_error(f'Failed to read cwd of {cwd_from} with error: {err}')
        else:
            cwd = os.path.expandvars(os.path.expanduser(cwd or os.getcwd()))
        self.cwd = os.path.abspath(cwd)
        self.stdin = stdin
        self.env = env or {}
        self.startup_command_via_shell_integration = startup_command_via_shell_integration
        self.final_env: dict[str, str] = {}
        self.is_default_shell = bool(self.argv and self.argv[0] == shell_path)
        self.should_run_via_run_shell_kitten = is_macos and self.is_default_shell
        self.hold = hold

    def get_final_env(self) -> tuple[dict[str, str], bool]:
        from kitty.options.utils import DELETE_ENV_VAR

        env = default_env().copy()
        opts = fast_data_types.get_options()
        boss = fast_data_types.get_boss()
        if (

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Verify the source process is alive and owned by you: `ls -l /proc/<pid>/cwd`
  2. Pass an explicit `--directory` instead of `--directory-from`
  3. Update kitty — shell-integration cwd extraction bugs are fixed over versions
Defensive patterns

Strategy: try-catch

Validate before calling

import os
pid = 1234
try:
    cwd = os.readlink(f'/proc/{pid}/cwd')
except OSError:
    cwd = os.path.expanduser('~')  # fall back explicitly

Try / catch

try: os.readlink(f'/proc/{pid}/cwd')\nexcept OSError: use fallback directory

Prevention

When it happens

Trigger: Using `--directory-from` / cwd_from pointing at a process whose /proc/<pid>/cwd is unreadable (permission denied, process exited, different user) or whose shell integration parsing fails.

Common situations: Pointing at a root-owned or already-dead PID; ssh-related cwd extraction failing because hold_after_ssh handling or shell parsing errors.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/9dc40d832400d4c9. Report an issue: GitHub.