GoogleContainerTools/skaffold · error
failed to create the tmp directory: %w
Error message
failed to create the tmp directory: %w
What it means
DownloadFromURL first creates the staging directory <ManifestTmpDir>/manifests-from-url where remote manifests will be written. If os.MkdirAll cannot create it (permission denied, read-only FS, path is a file), the download aborts with this wrapped error.
Source
Thrown at pkg/skaffold/kubernetes/manifest/url.go:36
import (
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)
var ManifestsFromURL = "manifests_from_url"
// DownloadFromURL downloads the provided manifests from their URLs,
// and returns a slice containing downloaded file destinations.
func DownloadFromURL(manifests []string) ([]string, error) {
dir := filepath.Join(ManifestTmpDir, ManifestsFromURL)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return nil, fmt.Errorf("failed to create the tmp directory: %w", err)
}
var paths []string
for _, manifest := range manifests {
out, err := downloadFromURL(dir, manifest)
if err != nil {
return nil, err
}
paths = append(paths, out)
}
return paths, nil
}
func downloadFromURL(destDir string, manifest string) (string, error) {
if manifest == "" || !util.IsURL(manifest) {
return "", fmt.Errorf("%s is not a valid URL", manifest)
}
View on GitHub (pinned to a1189de023)
Solutions
- Check and free/fix the tmp directory: ensure the path is not a file (rm the stale file) and the parent is writable
- Run the process with a user that has write access to ManifestTmpDir (often under os.TempDir()/HOME)
- Fix the environment (writable /tmp, non-readonly rootfs, free disk space) and retry
Defensive patterns
Strategy: validation
Validate before calling
dir := filepath.Join(ManifestTmpDir, ManifestsFromURL)
if st, err := os.Stat(dir); err == nil && !st.IsDir() {
return fmt.Errorf("%s exists and is not a directory", dir)
}
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return err
} Try / catch
paths, err := manifest.DownloadFromURL(urls)
if err != nil && strings.Contains(err.Error(), "failed to create the tmp directory") {
// fix permissions / remove stale file, then retry once
} Prevention
- Ensure TMPDIR/tmp staging paths are writable in your container image
- Remove stale files that may occupy the ManifestTmpDir path
- Check disk space before large render operations
When it happens
Trigger: Calling DownloadFromURL (via resolveRemoteAndLocal) when os.MkdirAll fails on ManifestTmpDir — e.g. tmp dir path exists as a regular file, or the process lacks write permission on the parent directory.
Common situations: Running in containers/sandboxes with read-only /tmp or restricted HOME; a leftover file occupying the tmp path from a previous crashed run; disk full.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- failed to write manifest to file, err: %w
- opening hydrated manifest at %s: %w
- writing string: %w
- writing string: %w
- writing buffer contents to file: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/9692d8fd283bc32e.
Report an issue: GitHub.