jesseduffield/lazydocker · error

{command output}

Error message

{command output}

What it means

RunPreparedCommand runs an exec.Cmd via CombinedOutput() and, if it fails, returns the combined stdout+stderr as the error text (falling back to the raw err only when output is empty). The '{command output}' placeholder is literal in the source — the real message is whatever the command printed. It exists so failures from prepared commands (with custom env) surface the subprocess's own diagnostics.

Source

Thrown at pkg/commands/os.go:289

			return false, nil
		}
		return false, err
	}
	return true, nil
}

// RunPreparedCommand takes a pointer to an exec.Cmd and runs it
// this is useful if you need to give your command some environment variables
// before running it
func (c *OSCommand) RunPreparedCommand(cmd *exec.Cmd) error {
	out, err := cmd.CombinedOutput()
	outString := string(out)
	c.Log.Info(outString)
	if err != nil {
		if len(outString) == 0 {
			return err
		}
		return errors.New(outString)
	}
	return nil
}

// GetLazydockerPath returns the path of the currently executed file
func (c *OSCommand) GetLazydockerPath() string {
	ex, err := os.Executable() // get the executable path for docker to use
	if err != nil {
		ex = os.Args[0] // fallback to the first call argument if needed
	}
	return filepath.ToSlash(ex)
}

// RunCustomCommand returns the pointer to a custom command
func (c *OSCommand) RunCustomCommand(command string) *exec.Cmd {
	return c.NewCmd(c.Platform.shell, c.Platform.shellArg, command)
}

View on GitHub (pinned to 7e7aadc207)

Solutions

  1. Read the returned message — it is the command's own stdout/stderr and contains the actual failure reason.
  2. Run the same command manually in a shell with the same environment to reproduce.
  3. If output is empty and you get a bare 'exit status N', inspect the exit code and check whether the binary exists at all (exec errors).
  4. For custom user commands in config, test the command string standalone before wiring it into lazydocker.
Defensive patterns

Strategy: try-catch

Try / catch

if err := osCommand.RunPreparedCommand(cmd); err != nil {
    // message == combined stdout+stderr of the command
    fmt.Fprintf(os.Stderr, "command failed:\n%s\n", err.Error())
    return err
}

Prevention

When it happens

Trigger: Any code path that builds an exec.Cmd (e.g. with extra env vars) and passes it to RunPreparedCommand where the command exits non-zero: failed docker CLI invocations, editor exits, custom commands from config.

Common situations: Custom commands defined in lazydocker config that fail; docker CLI auth/permission failures surfacing through prepared commands; attached commands whose output interleaves stdout and stderr making the error message noisy.

Related errors


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