fix(mktemp): X's must be trailing — breaks on macOS (2nd run) and Alpine (1st run) (#2370) - #2372
Open
noron12234 wants to merge 1 commit into
Open
fix(mktemp): X's must be trailing — breaks on macOS (2nd run) and Alpine (1st run) (#2370)#2372noron12234 wants to merge 1 commit into
noron12234 wants to merge 1 commit into
Conversation
BSD mktemp (macOS) only substitutes X's when they are the trailing characters of the template. With a suffix it creates a file whose name contains six literal X's, then every later run fails with "mkstemp failed: File exists" until TMPDIR is cleared. busybox mktemp (Alpine) is worse -- it rejects the template outright on the first run. Fixes the five sites in codex/SKILL.md.tmpl reported in garrytan#2370, plus the same bug in three places the issue didn't cover: claude/SKILL.md.tmpl RESP_FILE/.json, ERR_FILE/.txt, DIFF_FILE/.patch (PROMPT_FILE one line above was already correct) scripts/resolvers/review.ts CODEX_PROMPT_FILE/.txt -> office-hours/SKILL.md bin/gstack-developer-profile developer-profile.json.XXXXXX.tmp, x2 The suffixes carry no meaning -- nothing globs on them, cleanup is by variable -- so they are dropped. developer-profile keeps its .tmp marker, moved ahead of the X's. Generated SKILL.md files regenerated with bun run gen:skill-docs.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2370.
Scope
The issue reports the five
mktemptemplates incodex/SKILL.md.tmpl. The samemistake exists in three more places it doesn't mention, so this PR fixes all of them:
codex/SKILL.md.tmplcodex-{err,prompt,resp}-XXXXXX.txt← #2370claude/SKILL.md.tmpl…-response-XXXXXX.json,…-error-XXXXXX.txt,…-diff-XXXXXX.patchscripts/resolvers/review.tsgstack-codex-oh-XXXXXXXX.txt→office-hours/SKILL.mdbin/gstack-developer-profiledeveloper-profile.json.XXXXXX.tmpclaude/SKILL.md.tmplis the clearest tell — line 97 is already correct and the twolines directly under it are not:
Measured behaviour
Three platforms, same two templates:
codex-err-XXXXXX.txt(old)codex-err-XXXXXX(new)codex-err-XXXXXX.txt; run 2+ →mkstemp failed … File existsmktemp: : Invalid argumenton every run, including the firstOnly GNU tolerates a suffix, which is why this survived — Linux CI is green while
macOS and Alpine users hit it. Note Alpine fails on the first run, so it's not even
the delayed failure mode the issue describes.
bin/gstack-developer-profilefails differently: itstrap 'rm -f "$TMPOUT"' EXITusually cleans the literal file up, so single runs look fine. But the name is constant,
so two concurrent invocations collide on the same path and one process's trap deletes
the other's temp file — exactly the guarantee
mktempexists to provide:Fix
Move the X's to the end. The suffixes aren't load-bearing — nothing globs on them and
every cleanup is
rm -f "$VAR"— so they're dropped.developer-profilekeeps its.tmpmarker, moved ahead of the X's.Verification
bun run gen:skill-docs; the tracked diff is exactly6 files / 17 lines and every changed line is a
mktempline (git diff -U0filtered on non-
mktempcontent comes back empty).bun test test/gen-skill-docs.test.ts test/gen-skill-docs-idempotency.test.ts test/gen-skill-docs-out-dir.test.ts test/codex-hardening.test.ts→ 436 pass, 0 fail.Not included
The issue also notes the temp files are never cleaned up (
rm -f "$TMPERR"missing onsome paths) and that stale
codex-err-review-XXXXXX.txtartifacts from older revisionslinger. That's a separate change to the skill's control flow — happy to follow up if
you want it in the same pass.