{"record":{"id":"3a2a7f355a313d9b","repo":"kubernetes/kubernetes","slug":"creating-temp-directory-w","errorCode":null,"errorMessage":"creating temp directory: %w","messagePattern":"creating temp directory: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hack/apidiff-changelog/main.go","lineNumber":123,"sourceCode":"\t\t\tos.Exit(errExit.exitCode)\n\t\t}\n\t\tfmt.Fprintf(os.Stderr, \"Error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n}\n\n// runDiff runs the full API diff workflow: dumps API state for the base and target\n// revisions, compares each module, reports incompatibilities, and optionally updates\n// or patches CHANGELOG.md files.\n// Returns a non-nil error if any module has unresolved incompatible changes.\nfunc runDiff(opts runDiffOptions, dirs []string) error {\n\tif _, err := exec.LookPath(\"apidiff\"); err != nil {\n\t\treturn fmt.Errorf(\"apidiff binary not found in PATH; please install it with 'go install golang.org/x/exp/cmd/apidiff@latest'\")\n\t}\n\n\ttempDir, err := os.MkdirTemp(\"\", \"apidiff-\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating temp directory: %w\", err)\n\t}\n\tdefer func() { _ = os.RemoveAll(tempDir) }()\n\n\trepoRoot, err := filepath.Abs(opts.repoRoot)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolving repo root %q: %w\", opts.repoRoot, err)\n\t}\n\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting working directory: %w\", err)\n\t}\n\tdirs, err = normalizeDirs(cwd, repoRoot, dirs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"normalizing directories: %w\", err)\n\t}\n\n\tafterDir := filepath.Join(tempDir, \"after\")","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/hack/apidiff-changelog/main.go#L105-L141","documentation":"Returned from runDiff (main.go:123) when os.MkdirTemp(\"\", \"apidiff-\") fails. The tool creates a scratch temp directory to hold apidiff state files and git worktrees; this is its very first allocation. Failure is an OS-level inability to create a directory in the system temp dir.","triggerScenarios":"TMPDIR (/tmp) does not exist, is read-only, full, or the process lacks permission; the process has exhausted its file/inode quota; disk full.","commonSituations":"CI runner out of disk; container with read-only /tmp and no writable emptyDir; TMPDIR env var pointed at a deleted/unwritable path; node under disk pressure.","solutions":["Check the temp dir is writable: `mktemp -d` should succeed.","Free disk/inodes on the filesystem backing TMPDIR.","Point TMPDIR at a writable location: `export TMPDIR=/var/tmp/apidiff-work && mkdir -p $TMPDIR`.","If running in a container with a read-only root FS, mount a writable emptyDir at /tmp."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func ensureTempWritable() error {\n    dir := os.TempDir()\n    f, err := os.CreateTemp(dir, \".apidiff-writetest\")\n    if err != nil {\n        return fmt.Errorf(\"temp dir %q not writable: %w\", dir, err)\n    }\n    _ = f.Close()\n    _ = os.Remove(f.Name())\n    return nil\n}","typeGuard":null,"tryCatchPattern":"tempDir, err := os.MkdirTemp(\"\", \"apidiff-\")\nif err != nil {\n    return fmt.Errorf(\"create temp dir under %q: %w\", os.TempDir(), err)\n}","preventionTips":["Keep TMPDIR on a volume with adequate free space/inodes.","Mount a writable emptyDir at /tmp in CI containers with read-only root FS.","Monitor disk pressure on nodes hosting the tool."],"tags":["apidiff","tooling","filesystem","temp","kubernetes","environment"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}