{"record":{"id":"9dc40d832400d4c9","repo":"kovidgoyal/kitty","slug":"failed-to-read-cwd-of-cwd-from-with-error-err","errorCode":null,"errorMessage":"Failed to read cwd of {cwd_from} with error: {err}","messagePattern":"Failed to read cwd of (.+?) with error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/child.py","lineNumber":356,"sourceCode":"        is_clone_launch: str = '',\n        add_listen_on_env_var: bool = True,\n        hold: bool = False,\n        pass_fds: tuple[int, ...] = (),\n        remote_control_fd: int = -1,\n        hold_after_ssh: bool = False,\n        startup_command_via_shell_integration: Sequence[str] | str = (),\n    ):\n        self.is_clone_launch = is_clone_launch\n        self.id = next(child_counter)\n        self.add_listen_on_env_var = add_listen_on_env_var\n        self.argv = list(argv)\n        self.pass_fds = pass_fds\n        self.remote_control_fd = remote_control_fd\n        if cwd_from:\n            try:\n                cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv, env, hold_after_ssh=hold_after_ssh) or cwd\n            except Exception as err:\n                log_error(f'Failed to read cwd of {cwd_from} with error: {err}')\n        else:\n            cwd = os.path.expandvars(os.path.expanduser(cwd or os.getcwd()))\n        self.cwd = os.path.abspath(cwd)\n        self.stdin = stdin\n        self.env = env or {}\n        self.startup_command_via_shell_integration = startup_command_via_shell_integration\n        self.final_env: dict[str, str] = {}\n        self.is_default_shell = bool(self.argv and self.argv[0] == shell_path)\n        self.should_run_via_run_shell_kitten = is_macos and self.is_default_shell\n        self.hold = hold\n\n    def get_final_env(self) -> tuple[dict[str, str], bool]:\n        from kitty.options.utils import DELETE_ENV_VAR\n\n        env = default_env().copy()\n        opts = fast_data_types.get_options()\n        boss = fast_data_types.get_boss()\n        if (","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/child.py#L338-L374","documentation":"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.","triggerScenarios":"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.","commonSituations":"Pointing at a root-owned or already-dead PID; ssh-related cwd extraction failing because hold_after_ssh handling or shell parsing errors.","solutions":["Verify the source process is alive and owned by you: `ls -l /proc/<pid>/cwd`","Pass an explicit `--directory` instead of `--directory-from`","Update kitty — shell-integration cwd extraction bugs are fixed over versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\npid = 1234\ntry:\n    cwd = os.readlink(f'/proc/{pid}/cwd')\nexcept OSError:\n    cwd = os.path.expanduser('~')  # fall back explicitly","typeGuard":null,"tryCatchPattern":"try: os.readlink(f'/proc/{pid}/cwd')\\nexcept OSError: use fallback directory","preventionTips":["Prefer --directory over --directory-from when the source PID may die","Check process ownership before inheriting its cwd"],"tags":["kitty","cwd","child-process","procfs"],"backgroundTag":"working-directory-resolution-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}