lima-vm/lima · error

failed to read raw digest file %q: %w

Error message

failed to read raw digest file %q: %w

What it means

Companion to the invalid-digest case: getCached attempted to read the raw-image conversion digest file from the cache, but the read failed (file missing at that moment, permission denied, I/O error). The OS error is wrapped in this message.

Source

Thrown at pkg/downloader/downloader.go:363

					}
					shadData = converted
					if o.expectedDigest != "" {
						o.expectedDigest = rawDigest
						shadDigest = rawImgConvDigestPath
					}
				} else {
					shadData = rawImgConvPath
					if o.expectedDigest != "" {
						if currentDigestData, err := os.ReadFile(rawImgConvDigestPath); err == nil {
							currentDigest := strings.TrimSpace(string(currentDigestData))
							if d, err := digest.Parse(currentDigest); err == nil {
								o.expectedDigest = d
								shadDigest = rawImgConvDigestPath
							} else {
								return nil, fmt.Errorf("invalid digest in raw digest file %q: %w", rawImgConvDigestPath, err)
							}
						} else {
							return nil, fmt.Errorf("failed to read raw digest file %q: %w", rawImgConvDigestPath, err)
						}
					}
				}
			}
		}
	}

	ext := path.Ext(remote)
	logrus.Debugf("file %#q is cached as %#q", localPath, shadData)
	if _, err := os.Stat(shadDigest); err == nil {
		logrus.Debugf("Comparing digest %#q with the cached digest file %#q, not computing the actual digest of %#q",
			o.expectedDigest, shadDigest, shadData)
		if err := validateCachedDigest(shadDigest, o.expectedDigest); err != nil {
			return nil, err
		}
		if err := copyLocal(ctx, localPath, shadData, ext, o.decompress, "", ""); err != nil {
			return nil, err
		}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Check and fix permissions on the cache directory: `ls -l` the digest path; chown/chmod as needed.
  2. Remove the unreadable digest file so the cache entry is rebuilt from scratch.
  3. Verify the cache directory is on a writable, local filesystem.

Example fix

// before: permission denied reading ~/.cache/lima/.../raw.digest
$ sudo chown -R $(id -u):$(id -g) ~/.cache/lima
// after: read succeeds, download proceeds from cache
Defensive patterns

Strategy: validation

Validate before calling

if f, err := os.Open(digestPath); err != nil {
    return fmt.Errorf("cache unreadable, remove or fix permissions: %w", err)
} else {
    f.Close()
}

Try / catch

res, err := d.Download(ctx, "", url)
if err != nil && strings.Contains(err.Error(), "failed to read raw digest file") {
    // check cache perms/ownership, purge entry, retry
}

Prevention

When it happens

Trigger: During cache resolution, os.ReadFile(rawImgConvDigestPath) fails — e.g. permissions changed on ~/.cache/lima, the digest file was deleted between existence checks and reads, or NFS/home-dir sync issues make the file unreadable.

Common situations: Cache directory owned by another user (ran lima with sudo previously); read-only cache mounts; corrupted filesystems.

Related errors


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