From bc0b0e47529acabce45118e2cda3f42eae397970 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 13 Dec 2022 19:14:46 +1300 Subject: [PATCH] Possible fix for crash introduced in #1948 (#1963) * Possible fix for crash introduced in #1948 * fix root dir search logic Co-authored-by: Lincoln Stein --- ldm/invoke/globals.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ldm/invoke/globals.py b/ldm/invoke/globals.py index 283b191907..b15f579c9d 100644 --- a/ldm/invoke/globals.py +++ b/ldm/invoke/globals.py @@ -17,7 +17,12 @@ from argparse import Namespace Globals = Namespace() # This is usually overwritten by the command line and/or environment variables -Globals.root = osp.abspath(os.environ.get('INVOKEAI_ROOT') or osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'),'..')) or osp.expanduser('~/invokeai')) +if os.environ.get('INVOKEAI_ROOT'): + Globals.root = osp.abspath(os.environ.get('INVOKEAI_ROOT')) +elif os.environ.get('VIRTUAL_ENV'): + Globals.root = osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'), '..')) +else: + Globals.root = osp.abspath(osp.expanduser('~/invokeai')) # Where to look for the initialization file Globals.initfile = 'invokeai.init'