lima-vm/lima · error

cache did not contain %#q: %w

Error message

cache did not contain %#q: %w

What it means

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.

Source

Thrown at pkg/fileutils/download.go:60

	logrus.Debugf("res.ValidatedDigest=%v", res.ValidatedDigest)
	switch res.Status {
	case downloader.StatusDownloaded:
		logrus.Infof("Downloaded %s from %#q", description, f.Location)
	case downloader.StatusUsedCache:
		logrus.Infof("Using cache %#q", res.CachePath)
	default:
		logrus.Warnf("Unexpected result from downloader.Download(): %+v", res)
	}
	return res.CachePath, nil
}

// CachedFile checks if a file is in the cache, validating the digest if it is available. Returns path in cache.
func CachedFile(f limatype.File) (string, error) {
	res, err := downloader.Cached(f.Location,
		downloader.WithCache(),
		downloader.WithExpectedDigest(f.Digest))
	if err != nil {
		return "", fmt.Errorf("cache did not contain %#q: %w", f.Location, err)
	}
	return res.CachePath, nil
}

// Errors compose multiple into a single error.
// Errors filters out ErrSkipped.
func Errors(errs []error) error {
	var finalErr error
	for _, err := range errs {
		if errors.Is(err, ErrSkipped) {
			logrus.Debug(err)
		} else {
			finalErr = errors.Join(finalErr, err)
		}
	}
	if len(errs) > 0 && finalErr == nil {
		// errs only contains ErrSkipped
		finalErr = fmt.Errorf("%v", errs)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Run the normal download path once online so the file is cached
  2. Clear the stale cache entry and re-download so the digest matches
  3. Verify f.Digest in the template matches the artifact actually cached
  4. Ensure the cache directory for your LIMA_HOME is intact and accessible

Example fix

// before
cached, err := fileutils.CachedFile(f) // fails offline
// after
path, err := fileutils.DownloadFile(ctx, dest, f, decompress, desc, arch, formats) // download then use
Defensive patterns

Strategy: fallback

Validate before calling

// verify cache presence before relying on CachedFile
if _, err := os.Stat(cachePath); err != nil {
    // fall back to DownloadFile
}

Try / catch

path, err := fileutils.CachedFile(f)
if err != nil {
    if strings.Contains(err.Error(), "cache did not contain") {
        path, err = fileutils.DownloadFile(ctx, dest, f, decompress, desc, arch, formats)
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/b0d6cba8a3e5e2a3. Report an issue: GitHub.