lima-vm/lima · error
failed to inspect instance %#q: %w
Error message
failed to inspect instance %#q: %w
What it means
protectAction calls store.Inspect for each named instance; when the instance directory/yaml cannot be read or parsed, the error is wrapped as "failed to inspect instance" and collected (other instances still processed). It almost always wraps an os.ErrNotExist for a nonexistent instance name.
Source
Thrown at cmd/limactl/protect.go:36
Use: "protect INSTANCE [INSTANCE, ...]",
Short: "Protect an instance to prohibit accidental removal",
Long: `Protect an instance to prohibit accidental removal via the 'limactl delete' command.
The instance is not being protected against removal via '/bin/rm', Finder, etc.`,
Args: WrapArgsError(cobra.MinimumNArgs(1)),
RunE: protectAction,
ValidArgsFunction: protectBashComplete,
GroupID: advancedCommand,
}
return protectCommand
}
func protectAction(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
var errs []error
for _, instName := range args {
inst, err := store.Inspect(ctx, instName)
if err != nil {
errs = append(errs, fmt.Errorf("failed to inspect instance %#q: %w", instName, err))
continue
}
if inst.Protected {
logrus.Warnf("Instance %#q is already protected. Skipping.", instName)
continue
}
if err := inst.Protect(); err != nil {
errs = append(errs, fmt.Errorf("failed to protect instance %#q: %w", instName, err))
continue
}
logrus.Infof("Protected %#q", instName)
}
return errors.Join(errs...)
}
func protectBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return bashCompleteInstanceNames(cmd)
}View on GitHub (pinned to dd909d0973)
Solutions
- Check the name with `limactl list` and re-run protect with the exact instance name
- Create the instance first (`limactl start <template> --name <name>`) before protecting
- If LIMA_HOME is customized, ensure it matches the environment used to create the instance
Example fix
// before limactl protect ubunty // after limactl list limactl protect ubuntu
Defensive patterns
Strategy: try-catch
Validate before calling
limactl list | grep -qx "$inst" || { echo "instance $inst not found" >&2; exit 1; } Try / catch
err := protectCmd.Run()
if err != nil && strings.Contains(err.Error(), "failed to inspect instance") {
// instance missing: create it or fix the name/LIMA_HOME
}
if errors.Is(err, os.ErrNotExist) { /* name typo or wrong LIMA_HOME */ } Prevention
- Verify instance names with `limactl list` before protect/unprotect
- Set LIMA_HOME explicitly and consistently in scripts
- Create instances before attempting to protect them
When it happens
Trigger: `limactl protect <name>` where <name> has no instance directory under LIMA_HOME; corrupted/missing lima.yaml; wrong LIMA_HOME pointing at a different instance set.
Common situations: Typo in instance name; running protect before `limactl start` created the instance; pointing LIMA_HOME at a non-default location; partially deleted instance directory.
Related errors
- instance %q not found
- instance %#q not found
- instance %#q does not exist, run `limactl create %s` to crea
- failed to delete instance %#q: %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/09a449d7e527b0eb.
Report an issue: GitHub.