From b810868239cb506f1c7d244ffcbe4bf176d588f2 Mon Sep 17 00:00:00 2001 From: silentoplayz Date: Fri, 15 Aug 2025 04:17:47 -0400 Subject: [PATCH] fix: Alembic CLI commands from failing --- backend/open_webui/alembic.ini | 2 +- backend/open_webui/env.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/open_webui/alembic.ini b/backend/open_webui/alembic.ini index 4eff85f0c6..dccd8a3c12 100644 --- a/backend/open_webui/alembic.ini +++ b/backend/open_webui/alembic.ini @@ -10,7 +10,7 @@ script_location = migrations # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. -prepend_sys_path = . +prepend_sys_path = .. # timezone to use when rendering the date within the migration file # as well as the filename. diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index e561036408..b6ba940d94 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -17,14 +17,17 @@ from open_webui.constants import ERROR_MESSAGES # Load .env file #################################### -OPEN_WEBUI_DIR = Path(__file__).parent # the path containing this file -print(OPEN_WEBUI_DIR) +# Use .resolve() to get the canonical path, removing any '..' or '.' components +_this_file_path_resolved = Path(__file__).resolve() -BACKEND_DIR = OPEN_WEBUI_DIR.parent # the path containing this file -BASE_DIR = BACKEND_DIR.parent # the path containing the backend/ +# OPEN_WEBUI_DIR should be the directory where env.py resides (open_webui/) +OPEN_WEBUI_DIR = _this_file_path_resolved.parent -print(BACKEND_DIR) -print(BASE_DIR) +# BACKEND_DIR is the parent of OPEN_WEBUI_DIR (backend/) +BACKEND_DIR = OPEN_WEBUI_DIR.parent + +# BASE_DIR is the parent of BACKEND_DIR (open-webui-dev/) +BASE_DIR = BACKEND_DIR.parent try: from dotenv import find_dotenv, load_dotenv