abiosoft/colima · error

error editing config file: %w

Error message

error editing config file: %w

What it means

Returned by editConfigFile when the underlying waitForUserEdit call fails: either the temp file could not be created/written/closed, or — most commonly — launchEditor failed. launchEditor resolves the editor from --editor, $EDITOR, a vscode-terminal heuristic, then a vim/code/nano fallback list, and errors with 'no editor found in $PATH...' or the editor process's non-zero exit.

Source

Thrown at cmd/start.go:682

// 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")
	}

	defer func() {
		_ = os.Remove(tmpFile)
	}()
	if startCmdArgs.Flags.SaveConfig {
		if err := configmanager.SaveFromFile(tmpFile); err != nil {
			return c, err
		}
	}
	return configmanager.LoadFrom(tmpFile)
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Set a working editor explicitly: `EDITOR=vim colima start --edit` (or the --editor flag)
  2. Install an editor: `brew install vim` / apt-get install vim-tiny in containers
  3. Skip the interactive editor entirely: write the YAML yourself and start with the file, or use flags instead of --edit
  4. If the wrapped error mentions temp files, check TMPDIR is writable and disk has space

Example fix

# before
$ colima start --edit
Error: error editing config file: no editor found in $PATH, kindly set $EDITOR environment variable and try again

# after
$ EDITOR=nano colima start --edit
Defensive patterns

Strategy: validation

Validate before calling

// Replicate launchEditor's resolution before opening an interactive edit
editor := os.Getenv("EDITOR")
if editor != "" {
    if _, err := exec.LookPath(strings.Fields(editor)[0]); err != nil {
        log.Fatalf("$EDITOR %q not found in PATH", editor)
    }
} else {
    found := false
    for _, cand := range []string{"vim", "code", "nano"} {
        if _, err := exec.LookPath(cand); err == nil {
            found = true
            break
        }
    }
    if !found {
        log.Fatal("no editor available; set $EDITOR or install vim/nano")
    }
}

Try / catch

if err := editConfigFile(); err != nil {
    if strings.Contains(err.Error(), "no editor found in $PATH") {
        // guide user: set EDITOR or install an editor, then retry
    }
    if strings.Contains(err.Error(), "temporary file") {
        // TMPDIR/disk problem, not an editor problem
    }
}

Prevention

When it happens

Trigger: `colima start --edit` with $EDITOR pointing to a nonexistent command; headless/SSH session with none of vim/code/nano installed; the editor process exits non-zero (e.g. sh -c '$EDITOR file' fails); TMPDIR unwritable.

Common situations: Minimal containers or servers without an editor installed; EDITOR set to a GUI app that returns immediately with an error; vscode 'code' CLI not on PATH inside the integrated terminal.

Related errors


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