lima-vm/lima · error
could not detect a text editor binary, try setting $EDITOR
Error message
could not detect a text editor binary, try setting $EDITOR
What it means
OpenEditor launches an interactive editor (via editorcmd.Detect()) to modify YAML content; it returns this error when no editor binary can be found in the environment. Detect() relies on $EDITOR/$VISUAL or well-known editors being installed.
Source
Thrown at pkg/editutil/editutil.go:63
configDir, err := dirnames.LimaConfigDir()
if err != nil {
s += "# WARNING: failed to load the config dir\n"
s += "\n"
return s
}
s += fileWarning(filepath.Join(configDir, filenames.Default))
s += fileWarning(filepath.Join(configDir, filenames.Override))
return s
}
// OpenEditor opens an editor, and returns the content (not path) of the modified yaml.
//
// OpenEditor returns nil when the file was saved as an empty file, optionally with whitespaces.
func OpenEditor(ctx context.Context, content []byte, hdr string) ([]byte, error) {
editor := editorcmd.Detect()
if editor == "" {
return nil, errors.New("could not detect a text editor binary, try setting $EDITOR")
}
tmpYAMLFile, err := os.CreateTemp("", "lima-editor-")
if err != nil {
return nil, err
}
tmpYAMLPath := tmpYAMLFile.Name()
defer os.RemoveAll(tmpYAMLPath)
if _, err := tmpYAMLFile.Write(append([]byte(hdr), content...)); err != nil {
tmpYAMLFile.Close()
return nil, err
}
if err := tmpYAMLFile.Close(); err != nil {
return nil, err
}
editorCmd := exec.CommandContext(ctx, editor, tmpYAMLPath)
editorCmd.Env = os.Environ()
editorCmd.Stdin = os.StdinView on GitHub (pinned to dd909d0973)
Solutions
- Export EDITOR to an installed editor binary, e.g. `export EDITOR=vim` (or nano)
- Install an editor (apt install vim / nano) if none exists
- Set VISUAL if EDITOR is ignored in your shell environment
- Pipe YAML via stdin/file instead of the interactive edit flow when no TTY/editor is available
Example fix
// before limactl edit default // fails: could not detect a text editor binary // after export EDITOR=vim limactl edit default
Defensive patterns
Strategy: validation
Validate before calling
if os.Getenv("EDITOR") == "" && os.Getenv("VISUAL") == "" {
if _, err := exec.LookPath("vi"); err != nil {
return errors.New("no editor: set $EDITOR or install one")
}
} Try / catch
content, err := editutil.OpenEditor(ctx, yaml, hdr)
if err != nil {
if err.Error() == "could not detect a text editor binary, try setting $EDITOR" {
return fmt.Errorf("set $EDITOR and retry: %w", err)
}
return err
} Prevention
- Always export EDITOR in shell profiles used for lima management
- Install a terminal editor in containers/CI images if editing flows are used
- Prefer non-interactive workflows (stdin/file) when no TTY exists
When it happens
Trigger: Calling OpenEditor (used by limactl edit and template creation flows via editAction / chooseNextCreatorState) in an environment where $EDITOR and $VISUAL are unset and no common editor binary (vi, nano, vim, etc.) is on PATH.
Common situations: Running lima inside minimal containers, CI jobs, or slimmed server images without any editor installed; non-interactive SSH shells where $EDITOR is not exported.
Related errors
- could not execute editor %#q for a file %#q: %w
- cannot use both --tty and --yes flags at the same time
- failed to open TUI: %w; preserving guest synced workdir at %
- failed to start less: %w
- pattern %#q contains invalid character %#q at position %d
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/312f2bf5b01f36d9.
Report an issue: GitHub.