From 6dfb8cecac3a7d410ac505b1114d2cfc52d866cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 18 Apr 2022 19:32:26 +0200 Subject: [PATCH] Do not fail on missing HOME environment to get config directory Also use first the XDG_CONFIG_HOME and fallback to expanduser. --- tryton/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tryton/config.py b/tryton/config.py index 50326901a1..480efe17d0 100644 --- a/tryton/config.py +++ b/tryton/config.py @@ -22,8 +22,9 @@ def get_config_dir(): appdata = str(appdata, sys.getfilesystemencoding()) return os.path.join(appdata, '.config', 'tryton', __version__.rsplit('.', 1)[0]) - return os.path.join(os.environ['HOME'], '.config', 'tryton', - __version__.rsplit('.', 1)[0]) + config_path = os.getenv('XDG_CONFIG_HOME', os.path.join('~', '.config')) + return os.path.expanduser( + os.path.join(config_path, 'tryton', __version__.rsplit('.', 1)[0])) if not os.path.isdir(get_config_dir()):