Watch at EaseStories. Answers. Perspective.

Technology · PRACTICAL GUIDE

sort cannot create a temporary file? Prove the runtime path and capacity before changing TMPDIR

Resolve the directory GNU sort actually selected inside the failing process, test that exact filesystem, then accept the repair only after the unchanged sort produces verified output.

Original diagram tracing GNU sort temporary-directory selection into the failing runtime namespace and its filesystem capacity.
Original illustration: resolve the effective path in the failing process before changing TMPDIR. Watch at Ease

GNU sort may spill runs to temporary files when input exceeds its in-memory buffer. “Cannot create temporary file” identifies that creation failed; it does not prove that /tmp is full or that a host-visible scratch directory exists inside the failing service or container.

Preserve the exact command and execution context. Derive the effective temporary directory, inspect that path from the same runtime, separate existence and permission from blocks, inodes and quota, then rerun the unchanged job and verify its output.

Freeze the command and derive the effective directory

Save the exact argv, working directory, environment, input and output paths, stderr and exit status. Record every -T/--temporary-directory option and whether the wrapper or scheduler expands variables before GNU sort starts.

Resolve precedence from evidence: explicit -T directories, otherwise TMPDIR, otherwise /tmp. Keep empty or malformed values visible; do not silently substitute a path from your interactive shell.

Inspect the path inside the failing runtime

Enter or reproduce the same service user, job, container and mount namespace. Confirm the chosen directory and each parent exist there, resolve symlinks, and compare the process-specific mount view rather than the host’s convenient view.

Test creation, write, close, rename and removal of a harmless probe in that exact directory under the failing identity. A host-root test or a test in a different container does not clear the runtime path.

Separate permissions from capacity

Record ownership, mode, ACLs, read-only mount flags and any confinement policy. If the probe is denied, repair only the verified identity or mount rule; a world-writable workaround is not a diagnosis.

For the exact filesystem, record usable blocks and free inodes for the job identity, then check applicable user, group or project quota. A positive free-block value does not clear inode exhaustion, quota or filesystem-specific allocation failure.

Choose the smallest scoped repair

If the path is absent in a container, bind or configure an approved scratch path in that runtime. If capacity is the constraint, free or allocate space on the owning filesystem; if permissions or quota own the failure, change only that policy after review.

Use -T or a job-scoped TMPDIR when an alternate filesystem is intentional and sized for the workload. Preserve rollback, cleanup and confidentiality expectations because sort runs can contain sensitive input.

Rerun unchanged and verify the output

Repeat the original sort in the original runtime with the repaired boundary. Capture the effective directory, mount, stderr, exit status and peak scratch behavior; do not accept a shortened sample as the production exit test.

Verify output record count, ordering keys, expected duplicates or uniqueness policy, checksum or downstream parse, and the final atomic publication step. Stop if only a different shell works, the effective directory is still ambiguous, or the output cannot be reconciled.

Original decision diagram requiring path, capacity, unchanged execution and output validation before accepting a repair.
Original illustration: a different TMPDIR is a hypothesis; verified output is the exit test. Watch at Ease