{"record":{"id":"3dd05637d91580b9","repo":"GoogleContainerTools/skaffold","slug":"failed-to-create-the-tmp-directory-w-3dd056","errorCode":null,"errorMessage":"failed to create the tmp directory: %w","messagePattern":"failed to create the tmp directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/manifest/gcs.go","lineNumber":45,"sourceCode":")\n\nvar ManifestsFromGCS = \"manifests_from_gcs\"\n\ntype GCSClient interface {\n\t// Downloads the content that match the given src uri and subfolders.\n\tDownloadRecursive(ctx context.Context, src, dst string) error\n}\n\nvar GetGCSClient = func() GCSClient {\n\treturn &client.Native{}\n}\n\n// DownloadFromGCS downloads all provided manifests from a remote GCS bucket,\n// and returns a relative path pointing to the GCS temp dir.\nfunc DownloadFromGCS(manifests []string) (string, error) {\n\tdir := filepath.Join(ManifestTmpDir, ManifestsFromGCS)\n\tif err := os.MkdirAll(dir, os.ModePerm); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create the tmp directory: %w\", err)\n\t}\n\tfor _, manifest := range manifests {\n\t\tif manifest == \"\" || !strings.HasPrefix(manifest, gcsPrefix) {\n\t\t\treturn \"\", fmt.Errorf(\"%v is not a valid GCS path\", manifest)\n\t\t}\n\t\tgcs := GetGCSClient()\n\t\tif err := gcs.DownloadRecursive(context.Background(), manifest, dir); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to download manifests fom GCS: %w\", err)\n\t\t}\n\t}\n\treturn ManifestTmpDir, nil\n}\n","sourceCodeStart":27,"sourceCodeEnd":58,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/manifest/gcs.go#L27-L58","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"dir := filepath.Join(manifest.ManifestTmpDir, \"manifests-from-gcs\")\nif fi, err := os.Stat(dir); err == nil && !fi.IsDir() {\n  return fmt.Errorf(\"%s exists as a file; remove it before downloading\", dir)\n}\nif err := os.MkdirAll(filepath.Dir(dir), 0o755); err != nil {\n  return fmt.Errorf(\"temp area not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"path, err := manifest.DownloadFromGCS(manifests)\nif err != nil && strings.Contains(err.Error(), \"failed to create the tmp directory\") {\n  // check permissions/disk, optionally clean stale tmp dir, then retry once\n  os.RemoveAll(filepath.Join(manifest.ManifestTmpDir, \"manifests-from-gcs\"))\n  path, err = manifest.DownloadFromGCS(manifests)\n}","preventionTips":["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"],"tags":["filesystem","gcs","io"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}