{"record":{"id":"a8c4e0238364723a","repo":"lima-vm/lima","slug":"failed-to-calculate-digest-of-raw-image-w","errorCode":null,"errorMessage":"failed to calculate digest of raw image: %w","messagePattern":"failed to calculate digest of raw image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/downloader/downloader.go","lineNumber":509,"sourceCode":"\t}\n\tif err := rawTmpF.Close(); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to close raw tmp file %q: %w\", rawPathTmp, err)\n\t}\n\n\tif err := os.Remove(rawImgConvPath); err != nil && !errors.Is(err, os.ErrNotExist) {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to remove stale raw image %q: %w\", rawImgConvPath, err)\n\t}\n\tif err := os.Rename(rawPathTmp, rawImgConvPath); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to replace original with raw image: %w\", err)\n\t}\n\n\talgo := digest.Canonical\n\tif originalDigest != \"\" {\n\t\talgo = originalDigest.Algorithm()\n\t}\n\trawDigest, err := calculateFileDigest(rawImgConvPath, algo)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to calculate digest of raw image: %w\", err)\n\t}\n\n\trawDigestPath := filepath.Join(imgConvPath, \"raw.digest\")\n\trawDigestPathTmp := rawDigestPath + \".tmp\"\n\tdefer os.Remove(rawDigestPathTmp)\n\tif err := os.WriteFile(rawDigestPathTmp, []byte(rawDigest.String()), 0o644); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to write raw digest file: %w\", err)\n\t}\n\tif err := os.Remove(rawDigestPath); err != nil && !errors.Is(err, os.ErrNotExist) {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to remove stale raw digest file %q: %w\", rawDigestPath, err)\n\t}\n\tif err := os.Rename(rawDigestPathTmp, rawDigestPath); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to rename raw digest file: %w\", err)\n\t}\n\n\treturn rawImgConvPath, rawDigest, nil\n}\n","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/downloader/downloader.go#L491-L527","documentation":"Once the raw image is in place, its digest is computed with calculateFileDigest using the original digest's algorithm (or canonical sha256). If opening the raw file or hashing its stream fails, this error wraps the cause. The digest is later persisted as imgconv/raw.digest for cache validation.","triggerScenarios":"calculateFileDigest(rawImgConvPath, algo) fails: os.Open returns ENOENT (raw file removed by a racing process) or the algo.FromReader read fails with EIO while hashing a multi-GB image.","commonSituations":"Concurrent cache deletion removes raw between rename and hashing; failing disk sector hit during a long read of a large image; cache on a network mount that dropped mid-read.","solutions":["Retry the download — a transient EIO or racing removal is often resolved on a clean second attempt","Delete the cache entry directory and re-download so conversion and hashing happen atomically","Run filesystem/disk health checks (smartctl, fsck) if hashing repeatedly fails with I/O errors","Move the cache to reliable local storage instead of a network filesystem"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to calculate digest of raw image\") {\n    // clear entry and retry\n    os.RemoveAll(shadDir)\n    return downloadOnce()\n}","preventionTips":["Don't delete cache directories while limactl is running","Use local storage, not network mounts, for large image caches","Check disk health if hashing large images repeatedly fails","Allow enough I/O headroom — hashing multi-GB raw images is read-intensive"],"tags":["go","filesystem","digest","cache"],"backgroundTag":"file-read-io-error","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}