{"record":{"id":"6c7da00158ede7a7","repo":"GoogleContainerTools/skaffold","slug":"cannot-create-temp-file-w","errorCode":null,"errorMessage":"cannot create temp file: %w","messagePattern":"cannot create temp file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/helm/util.go","lineNumber":42,"sourceCode":"\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/graph\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util\"\n)\n\n// copy of cmd/skaffold/app/flags.BuildOutputs\ntype buildOutputs struct {\n\tBuilds []graph.Artifact `json:\"builds\"`\n}\n\nfunc writeBuildArtifacts(builds []graph.Artifact) (string, func(), error) {\n\tbuildOutput, err := json.Marshal(buildOutputs{builds})\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot marshal build artifacts: %w\", err)\n\t}\n\n\tf, err := os.CreateTemp(\"\", \"builds*.yaml\")\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot create temp file: %w\", err)\n\t}\n\tif _, err := f.Write(buildOutput); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot write to temp file: %w\", err)\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot close temp file: %w\", err)\n\t}\n\treturn f.Name(), func() { os.Remove(f.Name()) }, nil\n}\n\n// SanitizeFilePath is used to sanitize filepaths that are provided to the `setFiles` flag\n// helm `setFiles` doesn't work with the unescaped filepath separator (\\) for Windows or if there are unescaped tabs and spaces in the directory names.\n// So we escape all odd count occurrences of `\\` for Windows, and wrap the entire string in quotes if it has spaces.\n// This is very specific to the way helm handles its flags.\n// See https://github.com/helm/helm/blob/d55c53df4e394fb62b0514a09c57bce235dd7877/pkg/cli/values/options.\n// Otherwise the windows `syscall` package implements its own sanitizing for command args that's used by `exec.Cmd`.\n// See https://github.com/golang/go/blob/6951da56b0ae2cd4250fc1b0350d090aed633ac1/src/syscall/exec_windows.go#L27\nfunc SanitizeFilePath(s string, isWindowsOS bool) string {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/helm/util.go#L24-L60","documentation":"After marshaling the build artifacts, writeBuildArtifacts creates a temp file (builds*.yaml via os.CreateTemp). If temp-file creation fails (e.g. no writable temp directory), this error is returned and the post-renderer setup aborts.","triggerScenarios":"os.CreateTemp(\"\", \"builds*.yaml\") fails: TMPDIR is unwritable or nonexistent, /tmp is read-only, disk full, or too many open files (EMFILE) exhausted the fd limit.","commonSituations":"Locked-down containers with read-only rootfs; TMPDIR set to a path that doesn't exist; ulimit -n too low in CI; full tmpfs.","solutions":["Check disk space on the temp filesystem (`df -h $TMPDIR /tmp`)","Set TMPDIR to an existing writable directory: `export TMPDIR=$(mktemp -d)`","Raise the open-file limit: `ulimit -n 4096` (or fix fd leaks)","Remount tmp writable or use a container image with writable /tmp"],"exampleFix":"// CI before\nTMPDIR=/nonexistent skaffold deploy\n// after\nexport TMPDIR=$(mktemp -d) && skaffold deploy","handlingStrategy":"validation","validationCode":"TD=\"${TMPDIR:-/tmp}\"; test -d \"$TD\" && test -w \"$TD\" && df --output=avail \"$TD\" | awk 'NR==2{exit ($1<104857600)?1:0}' || { echo \"temp dir missing/unwritable or <100MB free\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure a writable temp directory exists (create TMPDIR if custom)","Watch for open-file limit exhaustion (ulimit -n) in long CI jobs","Give deploy containers writable /tmp (not a read-only rootfs)","Pre-clean old builds*.yaml temp files"],"tags":["temp-file","io","filesystem","helm"],"backgroundTag":"temp-file-write-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}