{"record":{"id":"abfc8865d7fccccc","repo":"GoogleContainerTools/skaffold","slug":"unable-to-create-temp-directory-q-w","errorCode":null,"errorMessage":"unable to create temp directory %q: %w","messagePattern":"unable to create temp directory %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/logfile/logfile.go","lineNumber":35,"sourceCode":"package logfile\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n)\n\n// Create creates or truncates a file to be used to output logs.\nfunc Create(path ...string) (*os.File, error) {\n\tlogfile := filepath.Join(os.TempDir(), \"skaffold\")\n\tfor _, p := range path {\n\t\tlogfile = filepath.Join(logfile, escape(p))\n\t}\n\n\tdir := filepath.Dir(logfile)\n\tif err := os.MkdirAll(dir, 0700); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create temp directory %q: %w\", dir, err)\n\t}\n\n\treturn os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)\n}\n\nvar escapeRegexp = regexp.MustCompile(`[^a-zA-Z0-9-_.]`)\n\nfunc escape(s string) string {\n\treturn escapeRegexp.ReplaceAllString(s, \"-\")\n}\n","sourceCodeStart":17,"sourceCodeEnd":46,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/logfile/logfile.go#L17-L46","documentation":"The logfile package builds a path under a temp/log root by joining escaped path segments, then creates the parent directory with 0700 permissions via os.MkdirAll before opening the log file. This error wraps the MkdirAll failure, meaning the directory for the log file could not be created. The wrapped OS error (permission denied, path exists as file, disk full) is the real cause.","triggerScenarios":"os.MkdirAll(dir, 0700) fails: parent path component is a regular file, read-only filesystem, permission denied, path too long, or disk errors.","commonSituations":"Running skaffold as a user without write access to the temp/cache directory; SKAFFOLD/xdg cache dir pointing at a read-only mount; a previous file named like the directory; containers running with read-only rootfs.","solutions":["Check the OS error in the message: if 'permission denied', chown/chmod the target directory or run with a user that can write there","If a non-directory exists at the path, remove/rename the offending file","Point logging at a writable location (adjust XDG_CACHE_HOME / TMPDIR or run with a writable --kubeconfig-agnostic cache path)","Verify the filesystem is writable (not read-only mount) and has free space"],"exampleFix":"// before: cache dir not writable\n$ skaffold dev\n// error: unable to create temp directory \"/home/user/.cache/skaffold\": mkdir ...: permission denied\n// after\n$ sudo chown -R $(whoami) ~/.cache/skaffold || export XDG_CACHE_HOME=/tmp/cache","handlingStrategy":"validation","validationCode":"// ensure the log root is writable before invoking Create\nroot := logRoot() // e.g. ~/.cache/skaffold\nif fi, err := os.Stat(root); err == nil && !fi.IsDir() {\n    return fmt.Errorf(\"%s exists and is not a directory; remove it\", root)\n}\nif err := os.MkdirAll(root, 0700); err != nil {\n    return fmt.Errorf(\"log root %s not writable: %w\", root, err)\n}","typeGuard":null,"tryCatchPattern":"lf, err := logfile.Create(path...)\nif err != nil && strings.Contains(err.Error(), \"unable to create temp directory\") {\n    // fall back to an OS temp dir\n    alt := filepath.Join(os.TempDir(), \"skaffold-logs\")\n    os.MkdirAll(alt, 0700)\n    lf, err = logfile.CreateWithRoot(alt, path...)\n}","preventionTips":["Run skaffold as a user with write access to the cache/temp dirs, or fix ownership with chown","Do not place files where directory names will be created (e.g. a file named 'skaffold' under .cache)","Point XDG_CACHE_HOME/TMPDIR at writable volumes in containers or read-only rootfs setups","Watch disk space; MkdirAll also fails on full or failing filesystems"],"tags":["filesystem","permissions","logfile"],"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"}