lima-vm/lima · error

unsupported log-format: %#q

Error message

unsupported log-format: %#q

What it means

limactl's --log-format global flag accepts a fixed set of formatter names (e.g. json, text). processGlobalFlags validates the value and returns this error from cmd/limactl/main.go:98 for anything unrecognized. It fails before any subcommand runs.

Source

Thrown at cmd/limactl/main.go:98

		}
		logrus.SetLevel(lvl)
	}

	logFormat, _ := rootCmd.Flags().GetString("log-format")
	switch logFormat {
	case "json":
		formatter := new(logrus.JSONFormatter)
		logrus.StandardLogger().SetFormatter(formatter)
	case "text":
		// logrus use text format by default.
		if runtime.GOOS == "windows" && isatty.IsCygwinTerminal(os.Stderr.Fd()) {
			formatter := new(logrus.TextFormatter)
			// the default setting does not recognize cygwin on windows
			formatter.ForceColors = true
			logrus.StandardLogger().SetFormatter(formatter)
		}
	default:
		return fmt.Errorf("unsupported log-format: %#q", logFormat)
	}
	return nil
}

func newApp() *cobra.Command {
	templatesDir := "$PREFIX/share/lima/templates"
	if exe, err := os.Executable(); err == nil {
		binDir := filepath.Dir(exe)
		prefixDir := filepath.Dir(binDir)
		templatesDir = filepath.Join(prefixDir, "share/lima/templates")
	}

	rootCmd := &cobra.Command{
		Use:     "limactl",
		Short:   "Lima: Linux virtual machines",
		Version: strings.TrimPrefix(version.Version, "v"),
		Example: fmt.Sprintf(`  Start the default instance:
  $ limactl start

View on GitHub (pinned to dd909d0973)

Solutions

  1. Use an accepted value: `--log-format json` or omit the flag for the default text format
  2. Check `limactl --help` for the exact list of supported log-format values
  3. Quote the value in scripts to avoid stray whitespace

Example fix

// before
limactl --log-format=pretty list
// after
limactl --log-format=json list
Defensive patterns

Strategy: validation

Validate before calling

case "$LOG_FORMAT" in ""|json|text) ;; *) echo "unsupported log-format: $LOG_FORMAT" >&2; exit 1;; esac

Try / catch

if err := processGlobalFlags(cmd); err != nil {
	if strings.HasPrefix(err.Error(), "unsupported log-format") {
		fmt.Fprintln(os.Stderr, "use --log-format json or text")
		os.Exit(2)
	}
	return err
}

Prevention

When it happens

Trigger: `limactl --log-format <value> ...` where <value> is not one of the supported names (json/text); scripts passing an unset/empty variable as the flag value.

Common situations: Typo like --log-format=json-formatted or --logformat; copying a flag value from another tool; shell var expansion producing an empty string for the flag.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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