abiosoft/colima · error

error in config file: %w

Error message

error in config file: %w

What it means

`colima start --edit` opens the profile's YAML in $EDITOR, then feeds the saved config through configmanager.ValidateConfig before using it. This error wraps validation failure: unknown/renamed keys, wrong value types (e.g. cpu as a string), out-of-range numbers, or structurally invalid YAML. The wrapped message names the offending field, and the VM is NOT started — the edit is rejected wholesale.

Source

Thrown at cmd/start.go:73

		conf := startCmdArgs.Config

		if !startCmdArgs.Flags.Edit {
			if app.Active() {
				log.Warnln("already running, ignoring")
				return nil
			}
			return start(app, conf)
		}

		// edit flag is specified
		conf, err := editConfigFile()
		if err != nil {
			return err
		}

		// validate config
		if err := configmanager.ValidateConfig(conf); err != nil {
			return fmt.Errorf("error in config file: %w", err)
		}

		if app.Active() {
			if !cli.Prompt("colima is currently running, restart to apply changes") {
				return nil
			}
			if err := app.Stop(false); err != nil {
				return fmt.Errorf("error stopping :%w", err)
			}
			// pause before startup to prevent race condition
			time.Sleep(time.Second * 3)
		}

		return start(app, conf)
	},
	PreRunE: func(cmd *cobra.Command, args []string) error {
		// validate Lima version
		if err := core.LimaVersionSupported(); err != nil {

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Read the wrapped message — it identifies the exact field; fix that key and re-run `colima start --edit`
  2. Regenerate a known-good baseline: revert to defaults in the editor and change one field at a time
  3. Skip the editor for simple changes: use `colima start --cpu 4 --memory 8` style flags; if hand-editing, check YAML syntax with yamllint first

Example fix

# before (edited config)
cpu: "4"        # error in config file: cpu: cannot unmarshal string into Go int
memory: 6

# after
cpu: 4
memory: 6
Defensive patterns

Strategy: validation

Validate before calling

// validate before trusting an edited config (Go, mirrors the CLI's own check)
if err := configmanager.ValidateConfig(conf); err != nil {
    fmt.Fprintf(os.Stderr, "config invalid: %v\n", err)
    os.Exit(1) // do NOT proceed to start
}

# shell: syntax-check the file before the start --edit round-trip
yamllint ~/.colima/_config/<profile>.yaml

Try / catch

if err := startCmd.Execute(); err != nil {
    if strings.Contains(err.Error(), "error in config file") {
        // the wrapped error names the bad field; fix the $EDITOR buffer and re-run,
        // or abandon the edit and start with flags: colima start --cpu 4 --memory 8
    }
}

Prevention

When it happens

Trigger: Saving the editor buffer with a typo or indentation error; carrying config keys from an older colima version after an upgrade; quoting numeric fields; emptying the file or saving it in the wrong format.

Common situations: Major colima upgrades renaming or moving settings; hand-crafting the YAML from blog posts; editors inserting tabs or stripping content; copy-pasting configs between profiles with divergent schemas.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/b81d39dd8bafe0a2. Report an issue: GitHub.