abiosoft/colima · error

error copying VM: %w

Error message

error copying VM: %w

What it means

Returned by `colima clone` (cmd/clone.go:50) when the external `cp` of basedisk, diffdisk, cidata.iso and lima.yaml from the source Lima instance dir into the destination fails. The %w carries the cp exit error.

Source

Thrown at cmd/clone.go:50

			// 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)
			}

			// ensure destination config directory
			if err := cli.Command("mkdir", "-p", filepath.Dir(to.LimaInstanceDir())).Run(); err != nil {
				return fmt.Errorf("cannot copy config to new profile '%s': %w", to.ShortName, err)
			}

			if err := cli.Command("cp", from.LimaInstanceDir(), to.LimaInstanceDir()).Run(); err != nil {
				return fmt.Errorf("error copying VM config: %w", err)
			}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Verify the four files exist in the source instance dir: `ls -la ~/.colima/_lima/<src-profile>`
  2. Start the source profile at least once (`colima start -p <src>`) so the disks are created, stop it, then clone
  3. Ensure free disk space on the destination at least the size of the source diffdisk (`df -h ~`)
  4. Clean up the partial destination dir before retrying, then rerun `colima clone`

Example fix

# before
colima clone neverstarted newprofile   # error copying VM: cp basedisk ... exit status 1

# after
colima start -p neverstarted && colima stop -p neverstarted
colima clone neverstarted newprofile
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: all four VM files must exist in the source instance dir
for _, f := range []string{"basedisk", "diffdisk", "cidata.iso", "lima.yaml"} {
    if _, err := os.Stat(filepath.Join(from.LimaInstanceDir(), f)); err != nil {
        return fmt.Errorf("source VM incomplete (missing %s); run `colima start -p %s` once first", f, from.ShortName)
    }
}

Prevention

When it happens

Trigger: Source files are missing (profile created but never started, so basedisk/diffdisk were never downloaded/created), permissions changed, or the disk filled up — diffdisk can be large (it is the VM's disk image).

Common situations: Cloning a profile that exists on disk but was never fully started; cloning while the source VM is running (file busy/changed); destination volume with less free space than the source diffdisk size.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/10d81ea29e7f68a7. Report an issue: GitHub.