lima-vm/lima · error
failed to rename %#q to %#q: %w
Error message
failed to rename %#q to %#q: %w
What it means
EnsureDisk wraps an os.Rename failure when moving the downloaded non-ISO image to its final disk path inside the instance directory. This library throws it because it cannot promote the downloaded image to the VM disk file. The wrapped os error (e.g. ENOENT, EXDEV, EACCES) is the actual cause.
Source
Thrown at pkg/driverutil/disk.go:107
os.Remove(diskPath)
_ = os.Rename(isoPath, imagePath)
return err
}
if err := diskUtil.Convert(ctx, diskImageFormat, diskPath, diskPath, &diskSizeInBytes, false); err != nil {
os.Remove(diskPath)
_ = os.Rename(isoPath, imagePath)
return fmt.Errorf("failed to create disk %#q: %w", diskPath, err)
}
} else {
format, err := nativeimgutil.DetectFormat(imagePath)
if err != nil {
return err
}
// Resize handled by prepareDisk() after CreateDisk()
if format == string(diskImageFormat) {
if err = os.Rename(imagePath, diskPath); err != nil {
return fmt.Errorf("failed to rename %#q to %#q: %w", imagePath, diskPath, err)
}
if err := os.Chmod(diskPath, 0o644); err != nil {
return fmt.Errorf("failed to chmod %#q: %w", diskPath, err)
}
} else {
if err := diskUtil.Convert(ctx, diskImageFormat, imagePath, diskPath, &diskSizeInBytes, false); err != nil {
return fmt.Errorf("failed to convert %#q to %#q: %w", imagePath, diskPath, err)
}
os.Remove(imagePath)
}
}
return nil
}
View on GitHub (pinned to dd909d0973)
Solutions
- Check the wrapped error for ENOENT/EACCES and verify imagePath and the instance directory exist and are writable
- Re-create the instance or re-download the image (limactl delete + limactl start) so the image file is present again
- Ensure instDir is on the same filesystem as the image (avoid moving ${LIMA_HOME} across mounts)
- Fix ownership/permissions on the instance directory (chown/chmod to the user running limactl)
Example fix
// before: image deleted externally, rename fails
// after: guard before starting or retry download
if _, err := os.Stat(imagePath); errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("image %s missing; re-download before EnsureDisk", imagePath)
} Defensive patterns
Strategy: validation
Validate before calling
imagePath := filepath.Join(instDir, "image")
if _, err := os.Stat(imagePath); err != nil {
return fmt.Errorf("image missing before EnsureDisk: %w", err)
}
if fi, err := os.Stat(instDir); err != nil || !fi.IsDir() {
return fmt.Errorf("instDir unusable: %w", err)
} Type guard
func canRename(dir string) bool {
f, err := os.CreateTemp(dir, ".probe-*")
if err != nil {
return false
}
name := f.Name()
f.Close()
os.Remove(name)
return true
} Try / catch
if err := driverutil.EnsureDisk(ctx, instDir, diskSize, format); err != nil {
var perr *os.PathError
if errors.As(err, &perr) {
// inspect perr.Err (ENOENT/EACCES/EXDEV) and recover: re-download or fix perms
}
return err
} Prevention
- Keep ${LIMA_HOME} on a single local filesystem to avoid EXDEV
- Never run cleanup jobs against an instance directory mid-start
- Run limactl as the same user that owns the instance files
When it happens
Trigger: Calling EnsureDisk (via CreateDisk) on a non-ISO image whose detected format equals the requested diskImageFormat, when os.Rename(imagePath, diskPath) fails: image file missing, instance dir removed mid-run, cross-device rename, or permission problem on instDir.
Common situations: Disk space/cleanup scripts deleted the downloaded image before EnsureDisk ran; instDir on a different filesystem after relocation; running limactl as a user without write access to the instance directory; concurrent lima processes racing on the same instance.
Related errors
- failed to create temp file: %w
- failed to write temp plist: %w
- failed to register instance %#q to start at login: %w
- failed to unregister instance %#q from start at login: %w
- instance %#q directory %#q exists but its %#q could not be r
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/00d82d90b017e113.
Report an issue: GitHub.