lima-vm/lima · error

`limactl network delete` currently always requires `--force`

Error message

`limactl network delete` currently always requires `--force`

What it means

`limactl network delete` performs no in-use check, so deletion is gated behind an explicit --force flag. The command intentionally refuses to run without it (comment in source: it does not verify whether the network is being used by instances).

Source

Thrown at cmd/limactl/network.go:287

`,
		Aliases:           []string{"remove", "rm"},
		Args:              WrapArgsError(cobra.MinimumNArgs(1)),
		RunE:              networkDeleteAction,
		ValidArgsFunction: networkBashComplete,
	}
	flags := cmd.Flags()
	flags.BoolP("force", "f", false, "Force delete (currently always required)")
	return cmd
}

func networkDeleteAction(cmd *cobra.Command, args []string) error {
	flags := cmd.Flags()
	force, err := flags.GetBool("force")
	if err != nil {
		return err
	}
	if !force {
		return errors.New("`limactl network delete` currently always requires `--force`")
		// Because the command currently does not check whether the network being removed is in use
	}

	networks := make([]string, len(args))
	for i, name := range args {
		networks[i] = fmt.Sprintf("del(.networks.%q)", name)
	}
	yq := strings.Join(networks, " | ")
	return networkApplyYQ(cmd.Context(), yq)
}

func networkBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
	return bashCompleteNetworkNames(cmd)
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Add --force: `limactl network delete --force <name>`
  2. Use the -f shorthand: `limactl network rm -f <name>`
  3. First verify no instance references the network (grep instance yaml for the network name), then delete with --force

Example fix

// before
limactl network delete mynet
// after
limactl network delete --force mynet
Defensive patterns

Strategy: validation

Validate before calling

grep -q "networks." ~/.lima/_config/networks.yaml && echo "network in use; review instances first"
limactl network delete --force "$name"

Prevention

When it happens

Trigger: Running `limactl network delete <name>` without --force.

Common situations: Interactive users forgetting the flag; scripts written before the flag became mandatory; aliases/scripts copying the older delete syntax without --force.

Related errors


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