{"record":{"id":"b0d6cba8a3e5e2a3","repo":"lima-vm/lima","slug":"cache-did-not-contain-q-w","errorCode":null,"errorMessage":"cache did not contain %#q: %w","messagePattern":"cache did not contain %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fileutils/download.go","lineNumber":60,"sourceCode":"\tlogrus.Debugf(\"res.ValidatedDigest=%v\", res.ValidatedDigest)\n\tswitch res.Status {\n\tcase downloader.StatusDownloaded:\n\t\tlogrus.Infof(\"Downloaded %s from %#q\", description, f.Location)\n\tcase downloader.StatusUsedCache:\n\t\tlogrus.Infof(\"Using cache %#q\", res.CachePath)\n\tdefault:\n\t\tlogrus.Warnf(\"Unexpected result from downloader.Download(): %+v\", res)\n\t}\n\treturn res.CachePath, nil\n}\n\n// CachedFile checks if a file is in the cache, validating the digest if it is available. Returns path in cache.\nfunc CachedFile(f limatype.File) (string, error) {\n\tres, err := downloader.Cached(f.Location,\n\t\tdownloader.WithCache(),\n\t\tdownloader.WithExpectedDigest(f.Digest))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cache did not contain %#q: %w\", f.Location, err)\n\t}\n\treturn res.CachePath, nil\n}\n\n// Errors compose multiple into a single error.\n// Errors filters out ErrSkipped.\nfunc Errors(errs []error) error {\n\tvar finalErr error\n\tfor _, err := range errs {\n\t\tif errors.Is(err, ErrSkipped) {\n\t\t\tlogrus.Debug(err)\n\t\t} else {\n\t\t\tfinalErr = errors.Join(finalErr, err)\n\t\t}\n\t}\n\tif len(errs) > 0 && finalErr == nil {\n\t\t// errs only contains ErrSkipped\n\t\tfinalErr = fmt.Errorf(\"%v\", errs)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/fileutils/download.go#L42-L78","documentation":"CachedFile checks the downloader's local cache for a file (validating its digest) without downloading; if downloader.Cached fails — the file isn't cached or the digest doesn't match — it wraps the error as \"cache did not contain %#q: %w\". It signals the offline fast-path cannot be satisfied.","triggerScenarios":"Calling CachedFile (via EnsureNerdctlArchiveCache) when the file was never downloaded into the lima cache, the cache entry was deleted, or the stored entry's digest fails validation against f.Digest.","commonSituations":"Running offline after clearing ~/.cache/lima; digest changed in a template so the cached artifact no longer validates; moving LIMA_HOME or copying caches incompletely between machines.","solutions":["Run the normal download path once online so the file is cached","Clear the stale cache entry and re-download so the digest matches","Verify f.Digest in the template matches the artifact actually cached","Ensure the cache directory for your LIMA_HOME is intact and accessible"],"exampleFix":"// before\ncached, err := fileutils.CachedFile(f) // fails offline\n// after\npath, err := fileutils.DownloadFile(ctx, dest, f, decompress, desc, arch, formats) // download then use","handlingStrategy":"fallback","validationCode":"// verify cache presence before relying on CachedFile\nif _, err := os.Stat(cachePath); err != nil {\n    // fall back to DownloadFile\n}","typeGuard":null,"tryCatchPattern":"path, err := fileutils.CachedFile(f)\nif err != nil {\n    if strings.Contains(err.Error(), \"cache did not contain\") {\n        path, err = fileutils.DownloadFile(ctx, dest, f, decompress, desc, arch, formats)\n    }\n    if err != nil { return err }\n}","preventionTips":["Prime the cache while online before offline use","Keep digests in templates consistent with cached artifacts","Don't clear ~/.cache/lima before offline operations","Keep LIMA_HOME stable across runs"],"tags":["download","cache","digest"],"backgroundTag":"cache-miss","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}