jesseduffield/lazydocker · error

No editor defined in $VISUAL or $EDITOR

Error message

No editor defined in $VISUAL or $EDITOR

What it means

Thrown by OSCommand.EditFile when no editor can be resolved: $VISUAL is empty, $EDITOR is empty, and `which vi` finds nothing. lazydocker uses the editor to open compose/config files (the 'e' key), and this chain is its entire fallback strategy — there is no built-in default beyond trying vi.

Source

Thrown at pkg/commands/os.go:193

	command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
	err := c.RunCommand(command)
	return err
}

// EditFile opens a file in a subprocess using whatever editor is available,
// falling back to core.editor, VISUAL, EDITOR, then vi
func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error) {
	editor := c.getenv("VISUAL")
	if editor == "" {
		editor = c.getenv("EDITOR")
	}
	if editor == "" {
		if err := c.RunCommand("which vi"); err == nil {
			editor = "vi"
		}
	}
	if editor == "" {
		return nil, errors.New("No editor defined in $VISUAL or $EDITOR")
	}

	return c.NewCmd(editor, filename), nil
}

// Quote wraps a message in platform-specific quotation marks
func (c *OSCommand) Quote(message string) string {
	var quote string
	if c.Platform.os == "windows" {
		quote = `\"`
		message = strings.NewReplacer(
			`"`, `"'"'"`,
			`\"`, `\\"`,
		).Replace(message)
	} else {
		quote = `"`
		message = strings.NewReplacer(
			`\`, `\\`,

View on GitHub (pinned to 7e7aadc207)

Solutions

  1. Export an editor in your shell profile: `export EDITOR=nano` (or vim/code) in ~/.bashrc or ~/.zshrc, then restart the terminal.
  2. Install vi/vim: `apt install vim` / `apk add vim` / `yum install vim-minimal`.
  3. Set VISUAL instead of/alongside EDITOR — it is checked first.
  4. For GUI launchers, ensure the environment variable is set globally (e.g. /etc/environment) since launcher-spawned processes don't read shell rc files.

Example fix

# before
# (nothing set; vi absent)
$ lazydocker   # pressing 'e' fails

# after
$ echo 'export EDITOR=vim' >> ~/.bashrc && source ~/.bashrc
$ lazydocker
Defensive patterns

Strategy: validation

Validate before calling

editor := os.Getenv("VISUAL")
if editor == "" {
    editor = os.Getenv("EDITOR")
}
if editor == "" {
    if _, err := exec.LookPath("vi"); err != nil {
        return fmt.Errorf("set $EDITOR (e.g. export EDITOR=vim) before using edit features")
    }
    editor = "vi"
}

Prevention

When it happens

Trigger: Pressing 'e' to edit a file (docker-compose.yml, service config) on a machine where VISUAL and EDITOR are unset and vi is not installed — most commonly minimal Docker containers, slim dev images, or fresh systems without vim.

Common situations: Running lazydocker inside a container (alpine/distroless without vi); environments launched from a GUI/launcher that drops shell env vars; Windows systems where EDITOR is rarely set; stripped-down servers with only nano installed.

Related errors


AI-assisted analysis of jesseduffield/lazydocker@7e7aadc207 (2026-08-15). Data as JSON: /api/errors/8bb1d5300bce5535. Report an issue: GitHub.