{"record":{"id":"d471251c6c169c4a","repo":"GoogleContainerTools/skaffold","slug":"failed-to-create-the-tmp-directory-w-d47125","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/util.go","lineNumber":47,"sourceCode":"\nconst (\n\tmanifestsStagingFolder       = \"manifest_tmp\"\n\trenderedManifestsStagingFile = \"rendered_manifest.yaml\"\n\tgcsPrefix                    = \"gs://\"\n)\n\nvar ManifestTmpDir = filepath.Join(os.TempDir(), manifestsStagingFolder)\n\n// Write writes manifests to a file, a writer or a GCS bucket.\nfunc Write(manifests string, output string, manifestOut io.Writer) error {\n\tswitch {\n\tcase output == \"\":\n\t\t_, err := fmt.Fprintln(manifestOut, manifests)\n\t\treturn err\n\tcase strings.HasPrefix(output, gcsPrefix):\n\t\ttempDir, err := os.MkdirTemp(\"\", manifestsStagingFolder)\n\t\tif err != nil {\n\t\t\treturn writeErr(fmt.Errorf(\"failed to create the tmp directory: %w\", err))\n\t\t}\n\t\tdefer os.RemoveAll(tempDir)\n\t\ttempFile := filepath.Join(tempDir, renderedManifestsStagingFile)\n\t\tif err := dumpToFile(manifests, tempFile); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgcs := client.Native{}\n\t\tif err := gcs.UploadFile(context.Background(), tempFile, output); err != nil {\n\t\t\treturn writeErr(fmt.Errorf(\"failed to copy rendered manifests to GCS: %w\", err))\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn dumpToFile(manifests, output)\n\t}\n}\n\nfunc dumpToFile(manifests string, filepath string) error {\n\tf, err := os.Create(filepath)","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/manifest/util.go#L29-L65","documentation":"ManifestList.Write with an output starting with gs:// first creates a temp staging directory via os.MkdirTemp. If that fails, the error is wrapped by writeErr as 'failed to create the tmp directory' and the manifests are not written.","triggerScenarios":"Calling Write (called from anonymous callers, e.g. render output handling) with output='gs://...' when os.MkdirTemp(\"\", manifestsStagingFolder) fails — typically TMPDIR pointing somewhere unwritable or nonexistent.","commonSituations":"TMPDIR env var set to a missing/unwritable path in CI or containers; read-only root filesystem; disk full.","solutions":["Fix or unset the TMPDIR environment variable so it points to a writable directory","Ensure the filesystem backing os.TempDir() has free space and write permission","Alternatively write rendered manifests to a local path instead of gs://"],"exampleFix":"# before\nexport TMPDIR=/nonexistent\n# after\nexport TMPDIR=/tmp  # writable directory","handlingStrategy":"validation","validationCode":"tmp := os.TempDir()\nif st, err := os.Stat(tmp); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"TMPDIR %q is not a usable directory\", tmp)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && errors.Is(pe.Err, os.ErrPermission) {\n        // point TMPDIR at a writable dir and retry\n    }\n    return err\n}","preventionTips":["Verify TMPDIR points to an existing writable directory in CI/containers","Set TMPDIR explicitly when running with restricted service users","Check free space on the tmp filesystem"],"tags":["filesystem","gcs","output","tempdir"],"backgroundTag":"tmpdir-unwritable","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"}