abiosoft/colima · error

error reading config file: %w

Error message

error reading config file: %w

What it means

Returned by editConfigFile, the `colima start --edit` path, when os.ReadFile on the current profile's config file fails. Since the config file is only created by a prior start, the dominant cause is 'no such file or directory' — there is no config to edit yet. Other causes are permission denial or the path being a directory.

Source

Thrown at cmd/start.go:671

		}
		if util.MacOSNestedVirtualizationSupported() {
			if !cmd.Flag("nested-virtualization").Changed {
				startCmdArgs.NestedVirtualization = current.NestedVirtualization
			}
		}
	}

	setFixedConfigs(&startCmdArgs.Config)
}

// editConfigFile launches an editor to edit the config file.
func editConfigFile() (config.Config, error) {
	var c config.Config

	// preserve the current file in case the user terminates
	currentFile, err := os.ReadFile(config.CurrentProfile().File())
	if err != nil {
		return c, fmt.Errorf("error reading config file: %w", err)
	}

	// prepend the config file with termination instruction
	abort, err := embedded.ReadString("defaults/abort.yaml")
	if err != nil {
		log.Warnln(fmt.Errorf("unable to read embedded file: %w", err))
	}

	tmpFile, err := waitForUserEdit(startCmdArgs.Flags.Editor, []byte(abort+"\n"+string(currentFile)))
	if err != nil {
		return c, fmt.Errorf("error editing config file: %w", err)
	}

	// if file is empty, abort
	if tmpFile == "" {
		return c, fmt.Errorf("empty file, startup aborted")
	}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Run a plain `colima start` once to generate the config file, then use `colima start --edit`
  2. If the file exists but is unreadable, fix ownership: `sudo chown -R "$USER" ~/.colima`
  3. Verify the expected path exists: `ls "$(colima status 2>/dev/null || true)"` or check under ~/.colima (or $COLIMA_HOME) for the profile's config
  4. Alternatively create the minimal config manually from the embedded default: `colima template` shows the shape of the YAML

Example fix

# before
$ colima start --edit
Error: error reading config file: open ~/.colima/_config/colima.yaml: no such file or directory

# after
$ colima start            # first start creates the config
$ colima start --edit     # now editable
Defensive patterns

Strategy: validation

Validate before calling

// Only offer the edit flow when a config already exists
home, _ := os.UserHomeDir()
f := filepath.Join(home, ".colima", "_config", "colima.yaml") // adjust for profile
if _, err := os.Stat(f); errors.Is(err, fs.ErrNotExist) {
    log.Println("no config yet; run `colima start` once before --edit")
    return
}

Try / catch

if _, err := editConfigFile(); err != nil {
    var pathErr *fs.PathError
    if errors.As(err, &pathErr) && errors.Is(pathErr.Err, fs.ErrNotExist) {
        // first-run: bootstrap by starting once, then retry edit
    }
}

Prevention

When it happens

Trigger: Running `colima start --edit` on a fresh install (never started, so config.CurrentProfile().File() does not exist); after `colima delete` removed the profile dir; config dir unreadable.

Common situations: New users following an 'edit your config' guide before the first start; scripting colima start --edit in CI on a clean machine; leftover root-owned ~/.colima after sudo use.

Related errors


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