mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[PR #16641] [MERGED] fix: Improve path resolution and Alembic configuration (also a fix) #47241
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16641
Author: @silentoplayz
Created: 8/15/2025
Status: ✅ Merged
Merged: 8/15/2025
Merged by: @tjbck
Base:
dev← Head:fix-alembic-migration-fails📝 Commits (1)
b810868fix: Alembic CLI commands from failing📊 Changes
2 files changed (+10 additions, -7 deletions)
View changed files
📝
backend/open_webui/alembic.ini(+1 -1)📝
backend/open_webui/env.py(+9 -6)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
devbranch.Changelog Entry
Description
This pull request updates the path handling in the
env.pyfile to usePath().resolve()for canonical path resolution, which helps in correctly determining the base directories. It also updates thealembic.iniconfiguration forprepend_sys_path.Changed
backend/open_webui/env.py:OPEN_WEBUI_DIRto_this_file_path_resolved.parent, where_this_file_path_resolvedisPath(__file__).resolve(), ensuring canonical path resolution.BACKEND_DIRto be the parent of the newly definedOPEN_WEBUII_DIR.BASE_DIRto be the parent of the newly definedBACKEND_DIR._this_file_path_resolved,OPEN_WEBUI_DIR,BACKEND_DIR, andBASE_DIR.backend/open_webui/alembic.ini:script_locationin the[alembic]section tomigrations.prepend_sys_pathfrom.to..in the[alembic]section.Removed
backend/open_webui/env.py:OPEN_WEBUI_DIR,BACKEND_DIR, andBASE_DIRthat relied directly onPath(__file__).parentwithoutresolve().print(OPEN_WEBUI_DIR),print(BACKEND_DIR), andprint(BASE_DIR)statements.Fixed
Path().resolve()to handle relative path components (..or.).backend/open_webui:Result AFTER the fix:
Breaking Changes
OPEN_WEBUI_DIR,BACKEND_DIR,BASE_DIR) has changed from direct.parentaccess to canonical resolution usingPath().resolve(). This might affect any external scripts or configurations that rely on specific non-canonical path interpretations.Additional Information
__file__might contain relative components or symlinks.alembic.iniadjustment forprepend_sys_pathensures that the alembic environment can correctly locate necessary modules by adjusting the Python system path.Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.