fix(codex): BSD mktemp templates broke /codex on every macOS install (#2091)

macOS mktemp requires the X's to end the template; the five
"codex-*-XXXXXX.txt" sites failed with "mkstemp failed ... File exists"
before Codex ever ran (reproduced live on this machine). Same class fixed
in claude/SKILL.md.tmpl's three sites. bin/gstack-paths now strips macOS's
trailing slash from TMPDIR so TMP_ROOT-built paths stop carrying "//".

Static tripwire scans every tracked .tmpl for characters after the X-run in
a mktemp template (longer X-runs stay valid), plus a live portability check
of the emitted shape.

Co-authored-by: Sina Matian <sina@time-attack.dev>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-14 11:51:55 -07:00
co-authored by Sina Matian Claude Fable 5
parent 6e8a1ae87f
commit d2e6925638
4 changed files with 71 additions and 8 deletions
+6
View File
@@ -55,6 +55,12 @@ elif [ -n "${TMP:-}" ]; then
else
_tmp_root=".gstack/tmp"
fi
# macOS exports TMPDIR with a trailing slash; mktemp templates built as
# "$TMP_ROOT/name-XXXXXX" would then carry "//", and any consumer comparing
# paths gets a spurious mismatch. Strip it (never strips a bare "/"). #2091
case "$_tmp_root" in
*/) [ "$_tmp_root" != "/" ] && _tmp_root="${_tmp_root%/}" ;;
esac
# Best-effort mkdir; if it fails (read-only fs, permission denied), the caller
# will discover that on their own write attempt. Don't fail the eval here.