From 42443e1f231f0337adcbab1c0031a47e5954eff3 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 14 May 2026 02:52:13 +0000 Subject: [PATCH] fix(cli): chdir nach lxc-frontend, damit pydantic-settings die .env findet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- lxc-frontend/app/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lxc-frontend/app/cli.py b/lxc-frontend/app/cli.py index 249578c..ca83121 100644 --- a/lxc-frontend/app/cli.py +++ b/lxc-frontend/app/cli.py @@ -17,13 +17,17 @@ Befehle: """ from __future__ import annotations +import os import sys 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 if str(_LXC_FRONTEND) not in sys.path: sys.path.insert(0, str(_LXC_FRONTEND)) +os.chdir(_LXC_FRONTEND) from sqlmodel import Session, select # noqa: E402