{"record":{"id":"5b7ccdd5616c1e6f","repo":"gohugoio/hugo","slug":"resource-q-not-found-in-file-cache","errorCode":null,"errorMessage":"resource %q not found in file cache","messagePattern":"resource %q not found in file cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/transform.go","lineNumber":626,"sourceCode":"\t\t\tif err != nil && err != herrors.ErrFeatureNotAvailable {\n\t\t\t\treturn nil, newErr(err)\n\t\t\t}\n\n\t\t\tif mayBeCachedOnDisk {\n\t\t\t\ttryFileCache = bcfg.UseResourceCache(err)\n\t\t\t}\n\t\t\tif err != nil && !tryFileCache {\n\t\t\t\treturn nil, newErr(err)\n\t\t\t}\n\t\t}\n\n\t\tif tryFileCache {\n\t\t\tf := r.target.tryTransformedFileCache(key, updates)\n\t\t\tif f == nil {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, newErr(err)\n\t\t\t\t}\n\t\t\t\treturn nil, newErr(fmt.Errorf(\"resource %q not found in file cache\", key))\n\t\t\t}\n\t\t\ttransformedContentr = f\n\t\t\tupdates.sourceFs = cache.fileCache.Fs\n\t\t\tdefer f.Close()\n\n\t\t\t// The reader above is all we need.\n\t\t\tbreak\n\t\t}\n\n\t\tif tctx.OutPath != \"\" {\n\t\t\ttctx.InPath = tctx.OutPath\n\t\t\ttctx.OutPath = \"\"\n\t\t}\n\t}\n\n\tif transformedContentr == nil {\n\t\tupdates.updateFromCtx(tctx)\n\t}","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/transform.go#L608-L644","documentation":"Returned by Spec.Transform when a transformation was skipped/deferred to the on-disk file cache (tryFileCache path, e.g. because useResourceCache is enabled or the tool was unavailable) but no cached file exists for the transformation key. newErr wraps a fresh error 'resource \"<key>\" not found in file cache'.","triggerScenarios":"The build is configured (or falls back) to read transformed resources from the file cache (resources/_gen), but the cache entry for the given transformation key is missing — typically because a tool was unavailable and no prior successful build populated the cache.","commonSituations":"Deploying to CI where the asset tool isn't installed and the prebuilt cache wasn't committed/copied; clearing the resources/_gen directory; changing transformation options so the cache key no longer matches a previously built artifact.","solutions":["Run the build once on a machine that has the required tool installed (postcss/babel/dart-sass) so the cache entry is generated.","Commit/copy the resources/_gen directory to the environment that lacks the tool, or ensure useResourceCache ('always'/'never') matches your intent.","Install the missing tool so the transformation runs live instead of relying on the cache."],"exampleFix":"// before: cache missing in CI\n$ hugo  // resource \"postcss/...\" not found in file cache\n\n// after: generate cache locally then ship it\n$ hugo --gc                       // locally, with postcss installed\n$ git add resources/_gen          // commit prebuilt artifacts\n$ CI runs hugo                    // uses the cache","handlingStrategy":"validation","validationCode":"// Ensure the cache entry exists for a transform key before relying on cache.\nfunc cacheEntryExists(cacheDir, key string) bool {\n    p := filepath.Join(cacheDir, \"resources\", key)\n    _, err := os.Stat(p)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate resources/_gen on a fully-tooled machine and ship it to tool-less environments.","Set useResourceCache explicitly ('always' for deploy, 'never' for dev) to match intent.","Don't change transformation options after caching — the key changes and the entry goes missing."],"tags":["cache","file-cache","resource-cache","asset-pipeline","feature-not-available"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}