lima-vm/lima · error

option --list-fields conflicts with option --yq

Error message

option --list-fields conflicts with option --yq

What it means

--list-fields only prints field names and produces no instance records, while --yq expects a document to query. Combining them is meaningless, so listAction rejects it whenever both --yq is set and listFields is true.

Source

Thrown at cmd/limactl/list.go:172

	}

	if jsonFormat {
		format = "json"
	}

	// conflicts
	if jsonFormat && cmd.Flags().Changed("format") {
		return errors.New("option --json conflicts with option --format")
	}
	if listFields && cmd.Flags().Changed("format") {
		return errors.New("option --list-fields conflicts with option --format")
	}
	if len(yq) != 0 {
		if cmd.Flags().Changed("format") && format != "json" && format != "yaml" {
			return errors.New("option --yq only works with --format json or yaml")
		}
		if listFields {
			return errors.New("option --list-fields conflicts with option --yq")
		}
	}
	if len(filter) != 0 {
		if listFields {
			return errors.New("option --list-fields conflicts with option --filter")
		}
	}

	if quiet && format != "table" {
		return errors.New("option --quiet can only be used with '--format table'")
	}

	if listFields {
		names := fieldNames()
		slices.Sort(names)
		fmt.Fprintln(cmd.OutOrStdout(), strings.Join(names, "\n"))
		return nil
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. List fields alone: `limactl list --list-fields`
  2. If you need to query instances with yq, drop --list-fields and use `--format json --yq '...'`

Example fix

// before
limactl list --list-fields --yq '.[]'
// after
limactl list --list-fields
Defensive patterns

Strategy: validation

Validate before calling

args := os.Args[1:]
if slices.Contains(args, "--list-fields") && slices.Contains(args, "--yq") {
    args = slices.DeleteFunc(args, func(a string) bool { return a == "--yq" || a == "--list-fields" })
}

Try / catch

if err := runList(); err != nil {
    if strings.Contains(err.Error(), "--list-fields conflicts with --yq") { /* split into two calls */ }
    return err
}

Prevention

When it happens

Trigger: Running `limactl list --list-fields --yq '.[]'` — len(yq) != 0 and listFields true reaches the conflict branch after the format checks pass.

Common situations: Trying to filter the field-name listing with yq; composing flags from separate examples.

Related errors


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