hashicorp/nomad · error
failed to generate logging UI
Error message
failed to generate logging UI
What it means
NewLogUI builds the logging UI (mitchellh/cli-based) used by `nomad ui` logging-related commands. It succeeds if it can wire either a colorized or basic UI from the provided options; if none of the known UI flavors could be constructed (the `found` flag stays false), it returns this error.
Source
Thrown at command/ui/log_ui.go:70
logUI.warnColor = coloredUI.WarnColor
logUI.underlyingUI = coloredUI.Ui
if basicUI, ok := coloredUI.Ui.(*cli.BasicUi); ok {
logUI.reader = basicUI.Reader
logUI.writer = basicUI.Writer
logUI.errorWriter = basicUI.ErrorWriter
found = true
}
} else if basicUI, ok := ui.(*cli.BasicUi); ok && !found {
logUI.reader = basicUI.Reader
logUI.writer = basicUI.Writer
logUI.errorWriter = basicUI.ErrorWriter
logUI.underlyingUI = basicUI
found = true
}
if !found {
return nil, errors.New("failed to generate logging UI")
}
return &logUI, nil
}
// Ask implements the Ask function of the cli.Ui interface.
func (l *LogUI) Ask(query string) (string, error) {
return l.underlyingUI.Ask(l.colorize(query, l.outputColor))
}
// AskSecret implements the AskSecret function of the cli.Ui interface.
func (l *LogUI) AskSecret(query string) (string, error) {
return l.underlyingUI.AskSecret(l.colorize(query, l.outputColor))
}
// Output implements the Output function of the cli.Ui interface.
func (l *LogUI) Output(message string) {
_, _ = fmt.Fprint(l.writer, l.colorize(message, l.outputColor))View on GitHub (pinned to 482b49bf1a)
Solutions
- Pass a valid, non-nil configuration: ensure the input/output/error writers (or a supported underlying cli.Ui) are provided so one of the code paths sets found=true.
- Use a plain basic UI (cli.NewBasicUi) as fallback input so at least the basic path succeeds.
- Update Nomad if hitting this with options that should be supported; check for regressions in ui/log_ui.go.
Example fix
// before
logUI, err := NewLogUI(nil) // no usable UI options
// after
basicUI := cli.NewBasicUi(cli.BasicUiOpts{Writer: os.Stdout, ErrorWriter: os.Stderr})
logUI, err := NewLogUI(basicUI) Defensive patterns
Strategy: validation
Validate before calling
if uiOpts == nil || (uiOpts.Writer == nil && uiOpts.ErrorWriter == nil) {
return errors.New("LogUI requires valid writer options")
} Type guard
func canBuildLogUI(o *LogUIOptions) bool { return o != nil && (o.Writer != nil || o.UnderlyingUI != nil) } Try / catch
logUI, err := NewLogUI(opts)
if err != nil && strings.Contains(err.Error(), "failed to generate logging UI") {
logUI = cli.NewBasicUi(cli.BasicUiOpts{Writer: os.Stdout, ErrorWriter: os.Stderr})
} Prevention
- Always pass a supported underlying cli.Ui or valid writers to NewLogUI.
- Fall back to cli.NewBasicUi when custom UI construction fails.
- Cover NewLogUI with unit tests for each supported option combination.
When it happens
Trigger: Calling NewLogUI with a configuration that matches neither the colorized nor the basic UI path — e.g. nil/invalid CLI options or UI configuration leaving no supported underlying UI available.
Common situations: Programmatic callers constructing the UI with incomplete cli.Ui options; embedding nomad command code with non-standard writers; misconfigured nomad UI setup.
Related errors
- failed to generate command UI
- Unknown log level
- No nomad log file defined
- eventlog.level must be one of INFO, WARN, or ERROR
- no default Consul services client
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/774a8351ca64bc83.
Report an issue: GitHub.