abiosoft/colima · error
error preparing to copy VM: %w
Error message
error preparing to copy VM: %w
What it means
Returned by `colima clone` (cmd/clone.go:40) when the external `mkdir -p <to.LimaInstanceDir()>` fails while preparing the destination directory for the copied VM files. The %w carries the mkdir exit error.
Source
Thrown at cmd/clone.go:40
from := config.ProfileFromName(args[0])
to := config.ProfileFromName(args[1])
logrus.Infof("preparing to clone %s...", from.DisplayName)
{
// verify source profile exists
if stat, err := os.Stat(from.LimaInstanceDir()); err != nil || !stat.IsDir() {
return fmt.Errorf("colima profile '%s' does not exist", from.ShortName)
}
// verify destination profile does not exists
if stat, err := os.Stat(to.LimaInstanceDir()); err == nil && stat.IsDir() {
return fmt.Errorf("colima profile '%s' already exists, delete with `colima delete %s` and try again", to.ShortName, to.ShortName)
}
// copy source to destination
logrus.Info("cloning virtual machine...")
if err := cli.Command("mkdir", "-p", to.LimaInstanceDir()).Run(); err != nil {
return fmt.Errorf("error preparing to copy VM: %w", err)
}
if err := cli.Command("cp",
filepath.Join(from.LimaInstanceDir(), "basedisk"),
filepath.Join(from.LimaInstanceDir(), "diffdisk"),
filepath.Join(from.LimaInstanceDir(), "cidata.iso"),
filepath.Join(from.LimaInstanceDir(), "lima.yaml"),
to.LimaInstanceDir(),
).Run(); err != nil {
return fmt.Errorf("error copying VM: %w", err)
}
}
{
logrus.Info("copying config...")
// verify source config exists
if _, err := os.Stat(from.LimaInstanceDir()); err != nil {
return fmt.Errorf("config missing for colima profile '%s': %w", from.ShortName, err)View on GitHub (pinned to c3a5f9184d)
Solutions
- Check ownership/permissions of the lima home: `ls -ld ~/.colima/_lima` and fix with `sudo chown -R $(id -un) ~/.colima/_lima` if needed
- Find and remove any regular file occupying the destination path or its parents
- Check free space with `df -h ~` and free space before retrying the clone
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: ensure the lima home parent is writable and path is clear
limaHome := filepath.Join(home, ".colima", "_lima")
if err := os.MkdirAll(limaHome, 0755); err != nil {
return fmt.Errorf("cannot prepare lima home: %w", err)
} Prevention
- Keep the colima home user-owned: avoid running colima under sudo
- Ensure adequate free disk before clones (VM disks are large)
- Never place regular files where colima expects directories (~/.colima/_lima)
When it happens
Trigger: The parent of the destination instance dir (the colima lima home, e.g. ~/.colima/_lima) is not writable by the current user, a regular file occupies a path component (mkdir -p fails), or the disk is full.
Common situations: Permissions on the lima home changed (e.g. created by root at some point); leftover file where a directory is expected; home volume out of space.
Related errors
- cannot copy config to new profile '%s': %w
- error reading ssh config: %w
- error modifying %s: %w
- config missing for colima profile '%s': %w
- error copying VM config: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/8040843895230d77.
Report an issue: GitHub.