{"record":{"id":"e511fbaab6ef02e5","repo":"GoogleContainerTools/skaffold","slug":"initializing-cache-w","errorCode":null,"errorMessage":"initializing cache: %w","messagePattern":"initializing cache: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/new.go","lineNumber":141,"sourceCode":"\n\t\tbuildDependencies, err := sourceDependencies.SingleArtifactDependencies(ctx, artifact, tag)\n\t\tif err != nil {\n\t\t\tendTrace(instrumentation.TraceEndError(err))\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttestDependencies, err := tester.TestDependencies(ctx, artifact)\n\t\tif err != nil {\n\t\t\tendTrace(instrumentation.TraceEndError(err))\n\t\t\treturn nil, err\n\t\t}\n\t\treturn append(buildDependencies, testDependencies...), nil\n\t}\n\n\tartifactCache, err := cache.NewCache(ctx, runCtx, isLocalImage, depLister, g, store)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"initializing cache: %w\", err)\n\t}\n\t// The Builder must be instantiated AFTER the Deployer, because the Deploy target influences\n\t// the Cluster object on the RunContext, which in turn influences whether or not we will push images.\n\tvar builder build.Builder\n\tbuilder, err = build.NewBuilderMux(runCtx, store, artifactCache, func(p latest.Pipeline) (build.PipelineBuilder, error) {\n\t\tpb, err := GetBuilder(ctx, runCtx, store, sourceDependencies, p)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn withPipelineBuildHooks(pb, p.Build.Hooks), nil\n\t})\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating builder: %w\", err)\n\t}\n\n\tbuilder, tester, renderer, deployer = WithTimings(builder, tester, renderer, deployer, runCtx.CacheArtifacts())\n\tif runCtx.Notification() {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/new.go#L123-L159","documentation":"`cache.NewCache` initializes the build cache (local or GCS-backed) that stores image build results keyed by artifact dependencies. This wraps its initialization failure in `NewForConfig`, stopping runner construction before any build.","triggerScenarios":"Local cache directory cannot be created/opened (permissions, read-only FS), or a remote cache backend (GCS bucket via `--cache-artifacts`/run context) cannot be reached or authenticated.","commonSituations":"CI containers with read-only $HOME so the local cache dir can't be created; cloud cache with missing GCS credentials/permissions; disk full on the machine hosting the cache.","solutions":["Read the wrapped error; fix cache backend access (credentials for GCS, or bucket existence/permissions).","Ensure the local cache directory location is writable (check $HOME/XDG paths, disk space).","Clear a potentially corrupt cache directory and retry.","Disable the cache temporarily (`--cache-artifacts=false` / remove cloud cache options) to unblock, then fix the backend."],"exampleFix":"// CI before (read-only HOME)\n$ skaffold build\n// initializing cache: creating cache dir: mkdir /home/ro: read-only file system\n// after (Dockerfile/CI)\nexport XDG_CACHE_HOME=/tmp/cache\nskaffold build","handlingStrategy":"validation","validationCode":"func cacheDirWritable() error {\n  dir := os.Getenv(\"XDG_CACHE_HOME\")\n  if dir == \"\" {\n    h, _ := os.UserHomeDir()\n    dir = filepath.Join(h, \".cache\")\n  }\n  probe := filepath.Join(dir, \".skaffold-cache-probe\")\n  if err := os.WriteFile(probe, nil, 0o644); err != nil {\n    return fmt.Errorf(\"cache dir %s not writable: %w\", dir, err)\n  }\n  os.Remove(probe)\n  return nil\n}","typeGuard":null,"tryCatchPattern":"runner, err := runner.NewForConfig(runCtx)\nif err != nil {\n  if strings.Contains(err.Error(), \"initializing cache\") {\n    log.Warn(\"cache unavailable; retrying with cache disabled\")\n    return runWithoutCache()\n  }\n  return err\n}","preventionTips":["Ensure $HOME/XDG cache paths are writable in CI (set XDG_CACHE_HOME=/tmp/cache if needed).","For GCS-backed caches, pre-verify credentials and bucket permissions with `gsutil ls`.","Monitor disk space on build hosts.","Keep a fallback path that runs with the cache disabled."],"tags":["cache","filesystem","gcs","build"],"backgroundTag":"cache-initialization-failed","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"}