From bdef6c6b9f6b8179b4b4221bf296e2e06394eae7 Mon Sep 17 00:00:00 2001 From: 1445043649 <> Date: Mon, 11 May 2026 17:35:23 +0800 Subject: [PATCH] fix(serve): auto-install postgres extras when config.yaml selects postgres MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/serve.sh 在 \`uv sync --quiet\` 前 grep config.yaml 探测 \`database.backend: postgres\`;若是则追加 \`--extra postgres\`,否则保持原状。 修一个 PR1+PR2 没覆盖到的隐患:serve.sh 每次 dev 启动都跑 uv sync,会把 之前手动 \`uv sync --extra postgres\` 装的 asyncpg 卸掉,导致 gateway 启动时 ImportError。 Stage 0 PR2 follow-up(不在原 plan task list 内,是 live 验证时发现)。 Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/serve.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/serve.sh b/scripts/serve.sh index 17d46eed..31b5e23b 100755 --- a/scripts/serve.sh +++ b/scripts/serve.sh @@ -158,8 +158,16 @@ fi # ── Install dependencies ──────────────────────────────────────────────────── if ! $SKIP_INSTALL; then + # Detect postgres backend in config.yaml so we install asyncpg + friends. + # Without this, `uv sync` strips the optional postgres extras between + # restarts and the gateway crashes at startup with "asyncpg is not installed". + UV_EXTRAS="" + if [ -f "$REPO_ROOT/config.yaml" ] && grep -qE "^[[:space:]]*backend:[[:space:]]*postgres" "$REPO_ROOT/config.yaml"; then + UV_EXTRAS="--extra postgres" + echo "Detected database.backend=postgres → installing postgres extras" + fi echo "Syncing dependencies..." - (cd backend && uv sync --quiet) || { echo "✗ Backend dependency install failed"; exit 1; } + (cd backend && uv sync --quiet $UV_EXTRAS) || { echo "✗ Backend dependency install failed"; exit 1; } (cd frontend && pnpm install --silent) || { echo "✗ Frontend dependency install failed"; exit 1; } echo "✓ Dependencies synced" else