From f12697c897a0b8d3a2bd783ae000af0a38ecf5e7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 3 Jul 2018 06:30:29 +0530 Subject: [PATCH] Better error when kitty config dir is a file See #697 --- kitty/constants.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kitty/constants.py b/kitty/constants.py index 99dda63e8..fd377ec63 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -58,7 +58,10 @@ def _get_config_dir(): candidate = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME') or '~/.config')) ans = os.path.join(candidate, appname) - os.makedirs(ans, exist_ok=True) + try: + os.makedirs(ans, exist_ok=True) + except FileExistsError: + raise SystemExit('A file {} already exists. It must be a directory, not a file.'.format(ans)) return ans