GoogleContainerTools/skaffold · error
failed to create the tmp directory: %w
Error message
failed to create the tmp directory: %w
What it means
DownloadFromGCS creates a local temp directory (ManifestTmpDir/ManifestsFromGCS) via os.MkdirAll before pulling manifests from GCS. If directory creation fails (permissions, existing file at that path, read-only filesystem), the OS error is wrapped as 'failed to create the tmp directory'.
Source
Thrown at pkg/skaffold/kubernetes/manifest/gcs.go:45
)
var ManifestsFromGCS = "manifests_from_gcs"
type GCSClient interface {
// Downloads the content that match the given src uri and subfolders.
DownloadRecursive(ctx context.Context, src, dst string) error
}
var GetGCSClient = func() GCSClient {
return &client.Native{}
}
// DownloadFromGCS downloads all provided manifests from a remote GCS bucket,
// and returns a relative path pointing to the GCS temp dir.
func DownloadFromGCS(manifests []string) (string, error) {
dir := filepath.Join(ManifestTmpDir, ManifestsFromGCS)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return "", fmt.Errorf("failed to create the tmp directory: %w", err)
}
for _, manifest := range manifests {
if manifest == "" || !strings.HasPrefix(manifest, gcsPrefix) {
return "", fmt.Errorf("%v is not a valid GCS path", manifest)
}
gcs := GetGCSClient()
if err := gcs.DownloadRecursive(context.Background(), manifest, dir); err != nil {
return "", fmt.Errorf("failed to download manifests fom GCS: %w", err)
}
}
return ManifestTmpDir, nil
}
View on GitHub (pinned to a1189de023)
Solutions
- Check and fix permissions on the directory containing ManifestTmpDir (ensure the running user can create directories there)
- If a regular file exists at the tmp-dir path, delete it so MkdirAll can create the directory
- Free disk space or remount the filesystem read-write
- Run with a writable TMPDIR / appropriate volume mounts in containers
Defensive patterns
Strategy: try-catch
Validate before calling
dir := filepath.Join(manifest.ManifestTmpDir, "manifests-from-gcs")
if fi, err := os.Stat(dir); err == nil && !fi.IsDir() {
return fmt.Errorf("%s exists as a file; remove it before downloading", dir)
}
if err := os.MkdirAll(filepath.Dir(dir), 0o755); err != nil {
return fmt.Errorf("temp area not writable: %w", err)
} Try / catch
path, err := manifest.DownloadFromGCS(manifests)
if err != nil && strings.Contains(err.Error(), "failed to create the tmp directory") {
// check permissions/disk, optionally clean stale tmp dir, then retry once
os.RemoveAll(filepath.Join(manifest.ManifestTmpDir, "manifests-from-gcs"))
path, err = manifest.DownloadFromGCS(manifests)
} Prevention
- Ensure the user running skaffold can write to the temp-dir parent (check TMPDIR in containers)
- Remove stale files that may occupy the tmp-dir path after crashed runs
- Mount writable scratch volumes in read-only container images
- Monitor disk space where skaffold runs
When it happens
Trigger: Calling manifest.DownloadFromGCS when os.MkdirAll on ManifestTmpDir/ManifestsFromGCS fails — e.g. a file already exists at that path, the parent dir is not writable, or the disk is full/read-only.
Common situations: Running skaffold in a container as non-root with a read-only or restricted temp filesystem, a stale regular file occupying the tmp-dir path from a previous crashed run, or HOME/cache volume mounted noexec/ro.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- writing string: %w
- writing string: %w
- writing buffer contents to file: %w
- failed to create directory: %v
- error opening file: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/3dd05637d91580b9.
Report an issue: GitHub.