{"record":{"id":"a9d5ab936af3c736","repo":"GoogleContainerTools/skaffold","slug":"failed-creating-remote-cache-directory-w","errorCode":null,"errorMessage":"failed creating remote cache directory: %w","messagePattern":"failed creating remote cache directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/gcs/gsutil.go","lineNumber":85,"sourceCode":"\n// GetGCSClient returns a GCS client that uses Client libraries.\nvar GetGCSClient = func() gscClient {\n\treturn &client.Native{}\n}\n\ntype gscClient 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\n// SyncObjects syncs the target Google Cloud Storage objects with skaffold's local cache and returns the local path to the objects.\nfunc SyncObjects(ctx context.Context, g latest.GoogleCloudStorageInfo, opts config.SkaffoldOptions) (string, error) {\n\tremoteCacheDir, err := config.GetRemoteCacheDir(opts)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed determining remote cache directory: %w\", err)\n\t}\n\tif err := os.MkdirAll(remoteCacheDir, 0700); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed creating remote cache directory: %w\", err)\n\t}\n\n\tsourceDir, err := getPerSourceDir(g)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed determining Google Cloud Storage remote cache directory for %q: %w\", g.Source, err)\n\t}\n\tcacheDir := filepath.Join(remoteCacheDir, sourceDir)\n\tif _, err := os.Stat(cacheDir); os.IsNotExist(err) {\n\t\t// If cache doesn't exist and cloning is disabled then we can't move forward.\n\t\tif opts.SyncRemoteCache.CloneDisabled() {\n\t\t\treturn \"\", syncDisabledErr(g, cacheDir)\n\t\t}\n\t\t// The subdirectory needs to exist to work with gsutil.\n\t\tif err := os.MkdirAll(cacheDir, 0700); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed creating Google Cloud Storage cache directory for %q: %w\", g.Source, err)\n\t\t}\n\t} else {\n\t\t// If sync property is false then skip fetching latest object from remote storage.","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/gcs/gsutil.go#L67-L103","documentation":"SyncObjects calls os.MkdirAll to create the local remote-cache directory (mode 0700) and wraps any filesystem failure. This is an environment/filesystem problem: the directory could not be created at the resolved path.","triggerScenarios":"os.MkdirAll(remoteCacheDir, 0700) fails because a parent path component is a file (ENOTDIR), permission denied (EACCES), read-only filesystem (EROFS), or disk/quota issues.","commonSituations":"Remote cache dir configured under a root-owned path while running as unprivileged user; pointing the cache dir at a path where a regular file already exists; running in a read-only container filesystem; full disk in CI.","solutions":["Check permissions on the parent directory: `ls -ld $(dirname <remoteCacheDir>)` and fix with chmod/chown","Ensure no regular file exists at the cache dir path; remove or rename it","Pick a writable cache dir (e.g. under $HOME or /tmp) via the remote-cache-dir option","Verify the filesystem is writable and has free space (`df -h`)"],"exampleFix":"// before\n--remote-cache-dir=/var/cache/skaffold\n// after\n--remote-cache-dir=$HOME/.skaffold/gcs-cache","handlingStrategy":"validation","validationCode":"dir, err := config.GetRemoteCacheDir(opts)\nif err != nil {\n\treturn fmt.Errorf(\"cannot resolve cache dir: %w\", err)\n}\nif fi, err := os.Stat(filepath.Dir(dir)); err != nil || !fi.IsDir() {\n\treturn fmt.Errorf(\"parent %s is not a writable directory\", filepath.Dir(dir))\n}\nif fi, err := os.Stat(dir); err == nil && !fi.IsDir() {\n\treturn fmt.Errorf(\"%s exists and is a file; remove it\", dir)\n}","typeGuard":"func isPathError(err error) (*os.PathError, bool) {\n\tvar pe *os.PathError\n\tok := errors.As(err, &pe)\n\treturn pe, ok\n}","tryCatchPattern":"if err := gcs.SyncObjects(ctx, gcsInfo, opts); err != nil {\n\tvar pe *os.PathError\n\tif errors.As(err, &pe) {\n\t\tlog.Errorf(\"fs error on %s: %v (check permissions/EROFS)\", pe.Path, pe.Err)\n\t}\n\treturn err\n}","preventionTips":["Configure the cache dir under a path your user owns (e.g. $HOME)","Ensure no file occupies the cache dir path before syncing","Check container images are not read-only where caching is used","Monitor disk space in CI runners","Create parent directories as part of environment setup"],"tags":["filesystem","directory","permissions","cache","go"],"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"}