GoogleContainerTools/skaffold · error
could not write build-artifacts: %w
Error message
could not write build-artifacts: %w
What it means
After locating the Skaffold binary, PrepareSkaffoldFilter serializes the build artifacts to a temp file that the post-renderer will read. If WriteBuildArtifacts fails (marshal or temp-file I/O), the error is wrapped as "could not write build-artifacts".
Source
Thrown at pkg/skaffold/helm/bin.go:157
cleanUp := func() {
Exec(ctx, h, out, false, nil, "plugin", "uninstall", helmPluginName)
os.RemoveAll(helmPluginDir)
}
return cleanUp, []string{"--post-renderer", helmPluginName}, nil
}
func PrepareSkaffoldFilter(h Client, builds []graph.Artifact, flags []string) (skaffoldBinary string, env []string, cleanup func(), err error) {
skaffoldBinary, err = OSExecutable()
if err != nil {
return "", nil, nil, fmt.Errorf("cannot locate this Skaffold binary: %w", err)
}
var buildsFile string
if len(builds) > 0 {
buildsFile, cleanup, err = WriteBuildArtifacts(builds)
if err != nil {
return "", nil, nil, fmt.Errorf("could not write build-artifacts: %w", err)
}
}
cmdLine := generateSkaffoldFilter(h, buildsFile, flags)
env = append(env, fmt.Sprintf("SKAFFOLD_CMDLINE=%s", shell.Join(cmdLine...)))
env = append(env, fmt.Sprintf("SKAFFOLD_FILENAME=%s", h.ConfigFile()))
return
}
// generateSkaffoldFilter creates a "skaffold filter" command-line for applying the various
// Skaffold manifest filters, such a debugging, image replacement, and applying labels.
func generateSkaffoldFilter(h Client, buildsFile string, flags []string) []string {
args := []string{"filter", "--kube-context", h.KubeContext()}
if h.EnableDebug() {
args = append(args, "--debugging")
for _, overrideProtocol := range h.OverrideProtocols() {
args = append(args, fmt.Sprintf("--protocols=%s", overrideProtocol))
}
}View on GitHub (pinned to a1189de023)
Solutions
- Check disk space (`df -h /tmp`) and free space or expand the volume
- Ensure TMPDIR points to a writable directory, or set TMPDIR explicitly
- Verify /tmp is not mounted read-only in the container
- Inspect the wrapped cause (marshal vs create vs write) in the error chain for the exact step
Defensive patterns
Strategy: validation
Validate before calling
test -w "${TMPDIR:-/tmp}" && df -h "${TMPDIR:-/tmp}" | awk 'NR==2{exit ($5+0>=95)?1:0}' || { echo "temp dir not writable or disk nearly full"; exit 1; } Prevention
- Keep /tmp writable with adequate free space in deploy environments
- Monitor disk usage in CI before deploy steps
- Set TMPDIR to a verified writable directory
- Clean stale temp files (builds*.yaml) regularly
When it happens
Trigger: WriteBuildArtifacts is called with a non-empty builds slice and any of its steps fail: json.Marshal of buildOutputs, os.CreateTemp, write, or close — commonly disk-full, read-only /tmp, or unwritable temp dir.
Common situations: Container with a full or read-only /tmp; TMPDIR pointing to a non-writable path; disk quota exceeded in CI; (indirectly) builds containing data that fails to marshal.
Related errors
- cannot create temp file: %w
- cannot write to 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/75bafc703d17f44d.
Report an issue: GitHub.