From 57f1bbb71aee87beb8f86350a107d609e80075f6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Mar 2018 10:54:49 +0530 Subject: [PATCH] Make cwd check more robust Apparently getcwd() raises an exception on macOS when the cwd does not exist. --- kitty/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kitty/main.py b/kitty/main.py index d1ee39ef0..0dc3a58e3 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -141,7 +141,11 @@ def _main(): if is_macos and os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1': os.chdir(os.path.expanduser('~')) args = macos_cmdline() - if not os.path.isdir(os.getcwd()): + try: + cwd_ok = os.path.isdir(os.getcwd()) + except Exception: + cwd_ok = False + if not cwd_ok: os.chdir(os.path.expanduser('~')) args, rest = parse_args(args=args) args.args = rest