From 88c9e96895063291e9e9c1f96ff97cb9df33d56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Thu, 13 Aug 2026 03:08:18 +0000 Subject: [PATCH] recover earlier answers on resume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A skipped section leaves its variables unset and later sections read them, so on a resume — which skips every section before the one that stopped — Build announced "PUBLIC_URL " on a machine whose .env had been written twenty minutes earlier. Three variables cross a section boundary: ENV_PORT and ENV_PUBLIC_URL from Environment, POSTGRES_URL from Database. They are read back once near the top, from the file that already holds the answers, rather than per-section — the next variable to cross would otherwise have to remember to do it again. Only fills what is empty, so a value passed on the command line still wins and a section that actually runs still overwrites it. Build had its own late read-back that made the generation work while the screen said it would not. Removed, now that the value is there before anything prints. Verified against the real install at /home/pastilhas/officerdev-test: --only Build now reports the URL that run chose. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/setup/officer-setup.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/setup/officer-setup.sh b/scripts/setup/officer-setup.sh index 7b63f30f..a6148ab3 100755 --- a/scripts/setup/officer-setup.sh +++ b/scripts/setup/officer-setup.sh @@ -141,6 +141,26 @@ info "Account: ${USERNAME} (home ${USER_HOME})" info "Officer: ${OFFICER_ROOT}" [[ -n "$MACHINE_ROLE" ]] && info "Role: ${MACHINE_ROLE}" +# ── recover what earlier runs already decided ── +# +# A skipped section leaves its variables unset, and later sections read them. On +# a resume that is every section before the one it stopped at, so Build announced +# "PUBLIC_URL " on a machine whose +# .env had been written twenty minutes earlier. +# +# Read back here, once, from the file that already holds the answers, rather than +# per-section — three variables cross a section boundary (ENV_PORT and +# ENV_PUBLIC_URL from Environment, POSTGRES_URL from Database) and the next one +# added would have to remember to do this again. +# +# Only fills what is EMPTY, so a variable passed in on the command line still +# wins, and a section that runs for real still overwrites it with its own answer. +if [[ -f "$(env_file)" ]]; then + ENV_PORT="${ENV_PORT:-$(env_get PORT)}" + ENV_PUBLIC_URL="${ENV_PUBLIC_URL:-$(env_get PUBLIC_URL)}" + POSTGRES_URL="${POSTGRES_URL:-$(env_get POSTGRES_URL)}" +fi + # ── is the machine actually ready ── # # Checked and reported together. Finding out about a missing bun three sections @@ -640,10 +660,6 @@ if ! skip; then echo " To change it later: bun gen:index https://your.new.url" echo "" - if [[ -z "${ENV_PUBLIC_URL:-}" ]]; then - ENV_PUBLIC_URL="$(env_get PUBLIC_URL)" - fi - if [[ -z "$ENV_PUBLIC_URL" ]]; then warn "PUBLIC_URL is not in $(env_file) — run the Environment section, then this one" SUMMARY+=("Build: SKIPPED — no PUBLIC_URL")