GoogleContainerTools/skaffold · error
cannot write to temp file: %w
Error message
cannot write to temp file: %w
What it means
writeBuildArtifacts writes the marshaled JSON to the temp file. If f.Write fails after successful creation, this error is returned, aborting post-renderer setup. It indicates an I/O problem on an already-open temp file handle.
Source
Thrown at pkg/skaffold/helm/util.go:45
)
// copy of cmd/skaffold/app/flags.BuildOutputs
type buildOutputs struct {
Builds []graph.Artifact `json:"builds"`
}
func writeBuildArtifacts(builds []graph.Artifact) (string, func(), error) {
buildOutput, err := json.Marshal(buildOutputs{builds})
if err != nil {
return "", nil, fmt.Errorf("cannot marshal build artifacts: %w", err)
}
f, err := os.CreateTemp("", "builds*.yaml")
if err != nil {
return "", nil, fmt.Errorf("cannot create temp file: %w", err)
}
if _, err := f.Write(buildOutput); err != nil {
return "", nil, fmt.Errorf("cannot write to temp file: %w", err)
}
if err := f.Close(); err != nil {
return "", nil, fmt.Errorf("cannot close temp file: %w", err)
}
return f.Name(), func() { os.Remove(f.Name()) }, nil
}
// SanitizeFilePath is used to sanitize filepaths that are provided to the `setFiles` flag
// helm `setFiles` doesn't work with the unescaped filepath separator (\) for Windows or if there are unescaped tabs and spaces in the directory names.
// So we escape all odd count occurrences of `\` for Windows, and wrap the entire string in quotes if it has spaces.
// This is very specific to the way helm handles its flags.
// See https://github.com/helm/helm/blob/d55c53df4e394fb62b0514a09c57bce235dd7877/pkg/cli/values/options.
// Otherwise the windows `syscall` package implements its own sanitizing for command args that's used by `exec.Cmd`.
// See https://github.com/golang/go/blob/6951da56b0ae2cd4250fc1b0350d090aed633ac1/src/syscall/exec_windows.go#L27
func SanitizeFilePath(s string, isWindowsOS bool) string {
if len(s) == 0 {
return `""`
}View on GitHub (pinned to a1189de023)
Solutions
- Check free space on the temp filesystem and clean up (`df -h; rm -rf /tmp/builds*`)
- Retry the operation after freeing disk/quota
- Point TMPDIR at a different, healthy filesystem
- If persistent, check dmesg/storage health for I/O errors
Defensive patterns
Strategy: validation
Validate before calling
TD="${TMPDIR:-/tmp}"; [ "$(stat -f -c %a "$TD" 2>/dev/null || df --output=avail "$TD" | tail -1)" -gt 104857600 ] || { echo "insufficient space on temp filesystem"; exit 1; } Prevention
- Keep generous free space on the filesystem backing TMPDIR
- Monitor disk I/O errors (dmesg) on CI runners
- Avoid network-mounted temp directories
- Clean tmpfs usage before deploy steps
When it happens
Trigger: f.Write(buildOutput) returns an error mid-write: disk became full, the underlying device returned EIO, or (in rare fd-exhaustion/edge cases) the write is interrupted with no short-write handling.
Common situations: tmpfs filling up between create and write; failing disk or network storage backing TMPDIR; storage quota exceeded in CI.
Related errors
- could not write build-artifacts: %w
- cannot create temp file: %w
- cannot close temp file: %w
- strings.Join(errMsgs, "\n") (joined helm cleanup error messa
- Failed to install Helm plugin
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/180816d2ebb93733.
Report an issue: GitHub.