lima-vm/lima · error

instance %#q not found

Error message

instance %#q not found

What it means

The instance name given as the source of a clone/rename does not exist in the Lima store. store.Inspect returned os.ErrNotExist, so cloneOrRenameAction converts it into this clearer message instead of leaking the raw store error. No instance directory with a readable lima.yaml exists under ${LIMA_HOME}/instances for that name.

Source

Thrown at cmd/limactl/clone.go:71

	renameCommand.Flags().Bool("start", false, "Start the instance after renaming")
	editflags.RegisterEdit(renameCommand, "[limactl edit] ")
	return renameCommand
}

func cloneOrRenameAction(cmd *cobra.Command, args []string) error {
	rename := cmd.Name() == "rename"
	ctx := cmd.Context()
	flags := cmd.Flags()
	tty, err := flags.GetBool("tty")
	if err != nil {
		return err
	}

	oldInstName, newInstName := args[0], args[1]
	oldInst, err := store.Inspect(ctx, oldInstName)
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			return fmt.Errorf("instance %#q not found", oldInstName)
		}
		return err
	}

	newInst, err := instance.CloneOrRename(ctx, oldInst, newInstName, rename)
	if err != nil {
		return err
	}

	yqExprs, err := editflags.YQExpressions(flags, false, newInst.Config.Param)
	if err != nil {
		return err
	}
	var start bool
	if len(yqExprs) > 0 {
		// TODO: reduce duplicated codes across cloneAction and editAction
		yq := yqutil.Join(yqExprs)
		filePath := filepath.Join(newInst.Dir, filenames.LimaYAML)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Run `limactl list` to see existing instance names and correct the spelling
  2. Verify LIMA_HOME points to the same store the instance was created in (default ~/.lima)
  3. Create the instance first with `limactl start` if it does not exist yet
  4. If the instance was deleted, restore it from backup or recreate it before cloning

Example fix

// before
$ limactl clone myvm1 myvm2
// instance "myvm1" not found
// after
$ limactl list
$ limactl clone myvm myvm2
Defensive patterns

Strategy: validation

Validate before calling

const instances = await listInstances()
if (!instances.some(i => i.name === oldName)) {
  throw new Error(`instance ${oldName} not found; run limactl list`)
}

Type guard

function instanceExists(name: string, instances: {name: string}[]): boolean {
  return instances.some(i => i.name === name)
}

Try / catch

try {
  await cloneOrRename(oldName, newName)
} catch (err) {
  if (/not found/.test(err.message)) {
    console.error(`Instance ${oldName} does not exist in this LIMA_HOME`)
  } else throw err
}

Prevention

When it happens

Trigger: `limactl clone <old> <new>` or `limactl rename <old> <new>` where <old> was never created, was already renamed/deleted, or is misspelled. Also triggered when the instance dir exists but lima.yaml is unreadable (that yields the other warning path in delete, but here Inspect returns ErrNotExist).

Common situations: Typo in instance name; running clone from a different LIMA_HOME; instance previously renamed; stale scripts referencing deleted instances.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/dc2198ec5e6ff451. Report an issue: GitHub.