lima-vm/lima · error
failed to convert image to raw: %w
Error message
failed to convert image to raw: %w
What it means
During fetch, the downloaded image's format did not match the supported formats, so ensureRawInCache was invoked to convert it to raw; that conversion failed, and the underlying error is wrapped with this message. The download cannot satisfy the caller's format requirement.
Source
Thrown at pkg/downloader/downloader.go:437
}
// If the driver cannot use the format we just downloaded, save a converted
// raw copy at <shad>/imgconv/raw, keeping the original <shad>/data as-is.
//
// Gated on WithImageFormats() (the caller's signal that this is a VM disk
// image) and on the file not being an ISO 9660 image.
if len(o.supportedImageFormats) > 0 {
isISO, err := iso9660util.IsISO9660(shadData)
if err != nil {
logrus.WithError(err).Debugf("Skipping cache image conversion for %q (unable to check ISO9660)", shadData)
} else if !isISO {
format, err := nativeimgutil.DetectFormat(shadData)
if err != nil {
logrus.WithError(err).Debugf("Skipping cache image conversion for %q (unable to detect format)", shadData)
} else if !slices.Contains(o.supportedImageFormats, format) {
converted, rawDigest, err := ensureRawInCache(ctx, shadData, format, o.expectedDigest)
if err != nil {
return nil, fmt.Errorf("failed to convert image to raw: %w", err)
} else if converted != "" {
shadData = converted
if o.expectedDigest != "" {
o.expectedDigest = rawDigest
}
}
}
}
}
// no need to pass the digest to copyLocal(), as we already verified the digest
if err := copyLocal(ctx, localPath, shadData, ext, o.decompress, "", ""); err != nil {
return nil, err
}
res := &Result{
Status: StatusDownloaded,
CachePath: shadData,
LastModified: readTime(shadTime),View on GitHub (pinned to dd909d0973)
Solutions
- Read the wrapped %w error to identify the conversion failure root cause (missing tool vs disk space).
- Free space in the cache directory (df -h; prune ~/.cache/lima).
- Install/repair the image conversion backend (e.g. qemu-img) or download an image already in the supported raw format.
Example fix
// before: conversion fails because qemu-img missing $ brew install qemu # or apt install qemu-utils // then retry the download; conversion succeeds
Defensive patterns
Strategy: try-catch
Validate before calling
if format, err := nativeimgutil.DetectFormat(localFile); err == nil && !slices.Contains(supportedFormats, format) {
log.Warnf("image %s (%s) will require raw conversion", localFile, format)
} Try / catch
res, err := d.Download(ctx, local, url)
if err != nil && strings.Contains(err.Error(), "failed to convert image to raw") {
// inspect wrapped cause; free cache space or install converter, then retry
} Prevention
- Download images already in the supported raw format when possible.
- Keep the cache volume with ample free space for raw conversions.
- Ensure conversion tooling (qemu-img equivalents) is installed on the host.
When it happens
Trigger: Download of a qcow2/vdi/etc image where nativeimgutil.DetectFormat succeeds but the format is unsupported, and ensureRawInCache fails (disk full during conversion, DiskUtil.Convert error, unsupported source format for the converter).
Common situations: Downloading VM images that need qemu-img-style conversion on hosts lacking the backing tool (e.g. qemu-img not installed or virtualization framework restrictions); cache dir out of space.
Related errors
- failed to convert %q 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/f52ae7a5bcb0a45a.
Report an issue: GitHub.