From 7697d44ddbd0feb4d364b5bb7924473434940824 Mon Sep 17 00:00:00 2001 From: mavneox Date: Thu, 30 Jul 2026 10:20:10 -0500 Subject: [PATCH] fix: expand build scratch dir in EXIT trap at set time The single-quoted trap read the function-local $scratch after scope exit; under set -u this turned every successful 'build' into exit 1 and skipped scratch cleanup. Expand at trap-set time instead. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/deploy_hosted.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/deploy_hosted.sh b/scripts/deploy_hosted.sh index b8fb0e6..eb4b41b 100644 --- a/scripts/deploy_hosted.sh +++ b/scripts/deploy_hosted.sh @@ -88,9 +88,13 @@ cmd_build() { require_sha local name scratch wheel name=$(venv_name_for_sha) - # Big scratch belongs on disk, never on the tmpfs. + # Big scratch belongs on disk, never on the tmpfs. Expand $scratch NOW + # (double quotes): a deferred single-quoted expansion reads the local var + # after it is out of scope at EXIT time, which under `set -u` turns a fully + # successful build into exit 1 (and skips the cleanup). scratch=$(mktemp -d "${TMPDIR:-/mnt/data/tmp}/gen-mcp-build.XXXXXX") - trap 'rm -rf "$scratch"' EXIT + # shellcheck disable=SC2064 + trap "rm -rf '$scratch'" EXIT echo "build: exporting $SHA and building wheel in $scratch" git -C "$REPO_DIR" archive "$SHA" | tar -x -C "$scratch" python3 -m pip wheel --no-deps --wheel-dir "$scratch/dist" "$scratch" >/dev/null