{"record":{"id":"8040843895230d77","repo":"abiosoft/colima","slug":"error-preparing-to-copy-vm-w","errorCode":null,"errorMessage":"error preparing to copy VM: %w","messagePattern":"error preparing to copy VM: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/clone.go","lineNumber":40,"sourceCode":"\t\tfrom := config.ProfileFromName(args[0])\n\t\tto := config.ProfileFromName(args[1])\n\n\t\tlogrus.Infof(\"preparing to clone %s...\", from.DisplayName)\n\t\t{\n\t\t\t// verify source profile exists\n\t\t\tif stat, err := os.Stat(from.LimaInstanceDir()); err != nil || !stat.IsDir() {\n\t\t\t\treturn fmt.Errorf(\"colima profile '%s' does not exist\", from.ShortName)\n\t\t\t}\n\n\t\t\t// verify destination profile does not exists\n\t\t\tif stat, err := os.Stat(to.LimaInstanceDir()); err == nil && stat.IsDir() {\n\t\t\t\treturn fmt.Errorf(\"colima profile '%s' already exists, delete with `colima delete %s` and try again\", to.ShortName, to.ShortName)\n\t\t\t}\n\n\t\t\t// copy source to destination\n\t\t\tlogrus.Info(\"cloning virtual machine...\")\n\t\t\tif err := cli.Command(\"mkdir\", \"-p\", to.LimaInstanceDir()).Run(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error preparing to copy VM: %w\", err)\n\t\t\t}\n\n\t\t\tif err := cli.Command(\"cp\",\n\t\t\t\tfilepath.Join(from.LimaInstanceDir(), \"basedisk\"),\n\t\t\t\tfilepath.Join(from.LimaInstanceDir(), \"diffdisk\"),\n\t\t\t\tfilepath.Join(from.LimaInstanceDir(), \"cidata.iso\"),\n\t\t\t\tfilepath.Join(from.LimaInstanceDir(), \"lima.yaml\"),\n\t\t\t\tto.LimaInstanceDir(),\n\t\t\t).Run(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error copying VM: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tlogrus.Info(\"copying config...\")\n\t\t\t// verify source config exists\n\t\t\tif _, err := os.Stat(from.LimaInstanceDir()); err != nil {\n\t\t\t\treturn fmt.Errorf(\"config missing for colima profile '%s': %w\", from.ShortName, err)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/clone.go#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight: ensure the lima home parent is writable and path is clear\nlimaHome := filepath.Join(home, \".colima\", \"_lima\")\nif err := os.MkdirAll(limaHome, 0755); err != nil {\n    return fmt.Errorf(\"cannot prepare lima home: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)"],"tags":["clone","filesystem","permissions","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}