fix(cli): chdir nach lxc-frontend, damit pydantic-settings die .env findet
Beim Aufruf aus /root oder anderen Verzeichnissen scheiterte der CLI mit PermissionError, weil pydantic-settings .env relativ zum Arbeitsverzeichnis liest und z. B. /root/.env stat-en wollte (für deploy nicht lesbar).
This commit is contained in:
parent
a681ca871b
commit
42443e1f23
@ -17,13 +17,17 @@ Befehle:
|
|||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Damit Skript auch ohne `cd` und ohne `-m` läuft: lxc-frontend/ auf sys.path.
|
# Damit das Skript aus jedem Verzeichnis funktioniert:
|
||||||
|
# 1) lxc-frontend/ auf sys.path → `from app.…` Imports funktionieren
|
||||||
|
# 2) chdir nach lxc-frontend/ → pydantic-settings findet ./.env (statt z. B. /root/.env)
|
||||||
_LXC_FRONTEND = Path(__file__).resolve().parent.parent
|
_LXC_FRONTEND = Path(__file__).resolve().parent.parent
|
||||||
if str(_LXC_FRONTEND) not in sys.path:
|
if str(_LXC_FRONTEND) not in sys.path:
|
||||||
sys.path.insert(0, str(_LXC_FRONTEND))
|
sys.path.insert(0, str(_LXC_FRONTEND))
|
||||||
|
os.chdir(_LXC_FRONTEND)
|
||||||
|
|
||||||
from sqlmodel import Session, select # noqa: E402
|
from sqlmodel import Session, select # noqa: E402
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user