GoogleContainerTools/skaffold · error

creating tar gz: %w

Error message

creating tar gz: %w

What it means

CreateDockerTarContext wraps a failure from util.CreateTar with 'creating tar gz'. After collecting dependency paths, Skaffold streams a tar.gz of those files into the writer; failures here are I/O or archiving problems, not dependency-resolution ones. The wrapped error carries the actual cause (write failure, unreadable file, context cancellation).

Source

Thrown at pkg/skaffold/docker/context.go:40

	"io"
	"path/filepath"

	"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)

func CreateDockerTarContext(ctx context.Context, w io.Writer, buildCfg BuildConfig, cfg Config) error {
	paths, err := GetDependenciesCached(ctx, buildCfg, cfg)
	if err != nil {
		return fmt.Errorf("getting relative tar paths: %w", err)
	}

	var p []string
	for _, path := range paths {
		p = append(p, filepath.Join(buildCfg.workspace, path))
	}

	if err := util.CreateTar(ctx, w, buildCfg.workspace, p); err != nil {
		return fmt.Errorf("creating tar gz: %w", err)
	}

	return nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Read the wrapped error to identify the failing file or write operation.
  2. Check disk space and that the destination of the writer is writable.
  3. Verify all files in the build context are readable (permissions) and exist (no racing deletions).
  4. Retry the build; transient I/O errors (network volumes, flaky mounts) often resolve on retry.

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

for _, p := range paths {
    if _, err := os.Stat(filepath.Join(buildCfg.workspace, p)); err != nil {
        return fmt.Errorf("dependency %s missing before tar: %w", p, err)
    }
}

Try / catch

err := CreateDockerTarContext(ctx, w, buildCfg, cfg)
if err != nil {
    if strings.Contains(err.Error(), "creating tar gz") {
        return fmt.Errorf("tar creation failed — check disk space, writer availability, and file permissions: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling CreateDockerTarContext where util.CreateTar fails: the destination writer errors (broken pipe, closed stream), a dependency file is unreadable or was deleted between listing and tarring, or the context is cancelled.

Common situations: Disk full when writing downstream; consumer of the writer closed early; a symlinked or permission-restricted file in the build context; very large contexts hitting timeouts; a file listed as a dependency removed by a concurrent build.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/3009019854a931d7. Report an issue: GitHub.