Summary
On macOS, /codex (all three modes) fails before Codex ever runs: the mktemp
calls that create the stderr/prompt/response temp files error out, the bash block
exits 1, and the user sees no review. Two compounding bugs, both in gstack.
Environment
- gstack: 1.58.4.0
- macOS: 26.5.1 (Apple silicon)
- mktemp: /usr/bin/mktemp (BSD)
- $TMPDIR: /var/folders/.../T/ (note the trailing slash — macOS default)
Symptom
mktemp: mkstemp failed on /var/folders/.../T//codex-err-XXXXXX.txt: File exists
mktemp: mkstemp failed on /var/folders/.../T//codex-prompt-XXXXXX.txt: File exists
/opt/homebrew/bin/bash: line 13: : No such file or directory
=== CODEX_EXIT=1 ===
(The empty TMPERR/_PROMPT_FILE vars then cascade into "No such file or directory"
for every later "$TMPERR" / cat "$_PROMPT_FILE".)
Root cause
- Suffix after the placeholder.
skills/codex/SKILL.md uses templates like
mktemp "$TMP_ROOT/codex-err-XXXXXX.txt" (also codex-prompt-XXXXXX.txt,
codex-resp-XXXXXX.txt). GNU mktemp tolerates a suffix after XXXXXX; BSD
mktemp (macOS) requires the placeholder at the END of the template and
mishandles the .txt suffix.
- Trailing slash in
TMP_ROOT. bin/gstack-paths emits TMP_ROOT straight
from $TMPDIR, which on macOS ends in /. The template then expands to a
double-slash path (…/T//codex-err-…), compounding the failure.
Affected code
skills/codex/SKILL.md (and SKILL.md.tmpl) — Steps 2A / 2B / 2C, every
mktemp "$TMP_ROOT/codex-*-XXXXXX.txt".
bin/gstack-paths — TMP_ROOT carries $TMPDIR's trailing slash.
Suggested fix
Drop the .txt suffix (X's at the end) and strip the trailing slash:
TR="${TMP_ROOT%/}"
TMPERR=$(mktemp "$TR/codex-err-XXXXXX")
_PROMPT_FILE=$(mktemp "$TR/codex-prompt-XXXXXX")
Either fix alone helps; both together is the robust portable form. Optionally have
gstack-paths normalize TMP_ROOT (_tmp_root="${_tmp_root%/}") so every skill
that consumes it benefits, not just /codex.
Repro
macOS, default $TMPDIR: run /codex review in any git repo. The first mktemp
in Step 2A fails.
Summary
On macOS,
/codex(all three modes) fails before Codex ever runs: themktempcalls that create the stderr/prompt/response temp files error out, the bash block
exits 1, and the user sees no review. Two compounding bugs, both in gstack.
Environment
Symptom
mktemp: mkstemp failed on /var/folders/.../T//codex-err-XXXXXX.txt: File exists
mktemp: mkstemp failed on /var/folders/.../T//codex-prompt-XXXXXX.txt: File exists
/opt/homebrew/bin/bash: line 13: : No such file or directory
=== CODEX_EXIT=1 ===
(The empty
TMPERR/_PROMPT_FILEvars then cascade into "No such file or directory"for every later
"$TMPERR"/cat "$_PROMPT_FILE".)Root cause
skills/codex/SKILL.mduses templates likemktemp "$TMP_ROOT/codex-err-XXXXXX.txt"(alsocodex-prompt-XXXXXX.txt,codex-resp-XXXXXX.txt). GNUmktemptolerates a suffix afterXXXXXX; BSDmktemp(macOS) requires the placeholder at the END of the template andmishandles the
.txtsuffix.TMP_ROOT.bin/gstack-pathsemitsTMP_ROOTstraightfrom
$TMPDIR, which on macOS ends in/. The template then expands to adouble-slash path (
…/T//codex-err-…), compounding the failure.Affected code
skills/codex/SKILL.md(andSKILL.md.tmpl) — Steps 2A / 2B / 2C, everymktemp "$TMP_ROOT/codex-*-XXXXXX.txt".bin/gstack-paths—TMP_ROOTcarries$TMPDIR's trailing slash.Suggested fix
Drop the
.txtsuffix (X's at the end) and strip the trailing slash: