fix(env): drop another checkout's values instead of preserving them

load.sh treats every already-set INFINITO_* as caller intent and restores it
after sourcing .env. In a worktree those values come from a different checkout,
so make requested the primary instance's subnet and docker refused the network
with "invalid pool request: Pool overlaps with other one on this address
space". Five retries, then the deploy died.

INFINITO_INSTANCE names the slot a value belongs to. When the environment
carries a different one than this checkout's .env, the whole set is foreign and
is dropped before .env loads. A caller in the same slot still wins, which eight
scripts under scripts/ rely on, and an unreadable .env yields no slot and
leaves the previous behaviour untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-23 12:39:35 +02:00
1 parent 8854694a21
commit 05e4dbafcb
1 file changed
+9
+9
View File
@@ -61,6 +61,15 @@ if [[ ! -f "${_infinito_env_dotenv}" ]]; then
) >&2
fi
_infinito_env_slot="$(sed -n 's/^INFINITO_INSTANCE=//p' "${_infinito_env_dotenv}" | head -1)"
if [[ -n "${_infinito_env_slot}" && -n "${INFINITO_INSTANCE:-}" && "${INFINITO_INSTANCE}" != "${_infinito_env_slot}" ]]; then
while IFS='=' read -r _infinito_env_key _; do
unset "${_infinito_env_key}"
done < <(env | grep '^INFINITO_')
unset _infinito_env_key
fi
unset _infinito_env_slot
declare -A _infinito_env_preserved=()
while IFS= read -r _infinito_env_line; do
case "${_infinito_env_line}" in