lima-vm/lima · error
failed to convert %q to raw: %w
Error message
failed to convert %q to raw: %w
What it means
ensureRawInCache converts a cached image to raw sparse format via proxyimgutil's DiskUtil.Convert; any failure from the converter is wrapped as this error, naming the source image path. It is the core "conversion step failed" error of the raw-image cache pipeline.
Source
Thrown at pkg/downloader/downloader.go:476
}
return res, nil
}
// ensureRawInCache converts any image to raw and places it in the cache(imgconv/raw). It also creates a
// digest file for the raw image(imgconv/raw.digest). Returns the converted image path, the raw digest, and any error.
func ensureRawInCache(ctx context.Context, imagePath, format string, originalDigest digest.Digest) (string, digest.Digest, error) {
imgConvPath := filepath.Join(filepath.Dir(imagePath), "imgconv")
if err := os.MkdirAll(imgConvPath, 0o700); err != nil {
return "", "", err
}
rawImgConvPath := filepath.Join(imgConvPath, "raw")
logrus.Infof("Converting %s image to raw sparse format in cache: %q", format, rawImgConvPath)
rawPathTmp := filepath.Join(imgConvPath, "raw.tmp")
defer os.Remove(rawPathTmp)
diskUtil := proxyimgutil.NewDiskUtil(ctx)
if err := diskUtil.Convert(ctx, raw.Type, imagePath, rawPathTmp, nil, false); err != nil {
return "", "", fmt.Errorf("failed to convert %q to raw: %w", imagePath, err)
}
// Ensure the image is sparse to save cache space.
rawTmpF, err := os.OpenFile(rawPathTmp, os.O_RDWR, 0o644)
if err != nil {
return "", "", fmt.Errorf("failed to open raw tmp file %q: %w", rawPathTmp, err)
}
fi, err := rawTmpF.Stat()
if err != nil {
_ = rawTmpF.Close()
return "", "", fmt.Errorf("failed to stat raw tmp file %q: %w", rawPathTmp, err)
}
if err := diskUtil.MakeSparse(ctx, rawTmpF, fi.Size()); err != nil {
logrus.WithError(err).Warnf("Failed to make %q sparse (non-fatal)", rawPathTmp)
}
if err := rawTmpF.Close(); err != nil {
return "", "", fmt.Errorf("failed to close raw tmp file %q: %w", rawPathTmp, err)
}View on GitHub (pinned to dd909d0973)
Solutions
- Inspect the wrapped %w error for the converter's own message (e.g. 'no space left on device').
- Free space in the cache/imgConv directory and remove stale raw.tmp files.
- Delete the corrupt cached source image and re-download.
- Install or update the conversion tooling the converter depends on.
Example fix
// before: ENOSPC during conversion $ df -h ~/.cache/lima && du -sh ~/.cache/lima/* $ rm -f ~/.cache/lima/images/*/raw.tmp // after: retry download; conversion completes
Defensive patterns
Strategy: try-catch
Validate before calling
if free, err := disk.Free(cacheDir); err == nil && free < minRequiredBytes {
return errors.New("cache volume too low on space for raw conversion")
} Try / catch
res, err := d.Download(ctx, local, url)
var convErr *fmt.WrapError // inspect via errors.Unwrap chain
if err != nil && strings.Contains(err.Error(), "failed to convert") {
if wrapped := errors.Unwrap(errors.Unwrap(err)); wrapped != nil {
log.Errorf("conversion root cause: %v", wrapped)
}
} Prevention
- Monitor free space on the CacheDir volume before large image downloads.
- Purge failed conversions (raw.tmp leftovers) after aborted runs.
- Verify image integrity/checksums to avoid converting corrupt sources.
When it happens
Trigger: DiskUtil.Convert fails inside ensureRawInCache (called from getCached or fetch) — source image unreadable, conversion backend unavailable, output volume full (raw.tmp write), or the image format cannot be converted by the selected raw.Type converter.
Common situations: Cache dir on a full or read-only volume; exotic/encrypted disk images the converter rejects; partial/corrupt source image in cache from an earlier failed download.
Related errors
- failed to convert image to raw: %w
- caching-only mode requires the cache directory to be specifi
- invalid digest in raw digest file %q: %w
- failed to read raw digest file %q: %w
- failed to open raw tmp file %q: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/3d49fe0232b75587.
Report an issue: GitHub.