From c5fff4ce8366b08669c0c8b6d30b99b94b9fefca Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 12 Sep 2026 16:15:16 +0200 Subject: fix(packaging): the hub unit can start, and nothing carries the migration path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ExecStartPre` ran `alembic -c /opt/meshbay-hub/migrations/alembic.ini upgrade head`. The build does stage that file, so the path existed and the contents were wrong: `alembic.ini` resolves `script_location` with `%(here)s`, so the copy pointed at `/opt/meshbay-hub/migrations/src/meshbay_hub/db/migrations` — which nothing installs, because the migrations ship inside `meshbay_hub`, in the shared venv. `ExecStartPre` failing stops the unit. A hub installed from the RPM or the DEB could not start at all, and nothing noticed because the one live deployment was assembled by hand — the same shape as the node unit that carried `User=` into the user unit directory. The same `%(here)s` trap was already found once on the server, where a stray `alembic.ini` resolved to a month-old snapshot of the tree. Twice is a trap rather than an accident, so the fix is that the path is no longer written down anywhere: `meshbay-hub migrate` asks the installed package where its own migrations are, which is correct for the RPM, the DEB, a venv and a checkout. The build stages no `alembic.ini`; the repo keeps its own for `alembic revision` and for deploy scripts that already work. `env.py` now prefers a URL the caller resolved over re-reading the environment itself, so `migrate --config` connects with exactly the string the server will — one resolution, not two that agree until they do not. Six tests, three of which fail against the unit as it was. They read the directives rather than the file, because searching the whole thing finds the comment explaining a directive and calls that the directive. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01T4YmK41VsEURWFdop4EEeT --- packaging/build/build-hub.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'packaging/build/build-hub.sh') diff --git a/packaging/build/build-hub.sh b/packaging/build/build-hub.sh index be2d363..e32ba55 100755 --- a/packaging/build/build-hub.sh +++ b/packaging/build/build-hub.sh @@ -47,11 +47,15 @@ ln -sf /opt/meshbay-common/venv/bin/meshbay-hub "$ROOT/usr/bin/meshbay-hub" # --- Hub-specific assets -------------------------------------------------- mkdir -p "$ROOT/opt/meshbay-hub" -# Alembic config (migrations are inside the installed package at meshbay_hub/db/migrations/) -if [ -f "$REPO/packages/meshbay-hub/alembic.ini" ]; then - mkdir -p "$ROOT/opt/meshbay-hub/migrations" - cp "$REPO/packages/meshbay-hub/alembic.ini" "$ROOT/opt/meshbay-hub/migrations/" -fi +# No alembic.ini is staged. It resolves `script_location` with `%(here)s`, so a +# copy of it is only correct where it was copied from: staged into +# /opt/meshbay-hub/migrations/ it pointed at +# /opt/meshbay-hub/migrations/src/meshbay_hub/db/migrations, which nothing +# installs — the migrations live inside the package, in the shared venv. The +# unit runs `meshbay-hub migrate` instead, which asks the package. +# +# The same `%(here)s` trap had already been found once on the server, where a +# stray alembic.ini resolved to a month-old snapshot of the tree. # Config example. # -- cgit v1.2.3