{"record":{"id":"86f17501f1f12fa7","repo":"wagoodman/dive","slug":"failed-to-set-ui-w-86f175","errorCode":null,"errorMessage":"failed to set UI: %w","messagePattern":"failed to set UI: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/command/root.go","lineNumber":43,"sourceCode":"func Root(app clio.Application) *cobra.Command {\n\topts := &rootOptions{\n\t\tApplication: options.DefaultApplication(),\n\t}\n\treturn app.SetupRootCommand(&cobra.Command{\n\t\tUse:   \"dive [IMAGE]\",\n\t\tShort: \"Docker Image Visualizer & Explorer\",\n\t\tLong: `This tool provides a way to discover and explore the contents of a docker image. Additionally the tool estimates\nthe amount of wasted space and identifies the offending files from the image.`,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"exactly one argument is required\")\n\t\t\t}\n\t\t\topts.Analysis.Image = args[0]\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, _ []string) error {\n\t\t\tif err := setUI(app, opts.Application); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to set UI: %w\", err)\n\t\t\t}\n\n\t\t\tresolver, err := dive.GetImageResolver(opts.Analysis.Source)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot determine image provider to fetch from: %w\", err)\n\t\t\t}\n\n\t\t\tctx := cmd.Context()\n\n\t\t\timg, err := adapter.ImageResolver(resolver).Fetch(ctx, opts.Analysis.Image)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot load image: %w\", err)\n\t\t\t}\n\n\t\t\treturn run(ctx, opts.Application, img, resolver)\n\t\t},\n\t}, opts)\n}","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/root.go#L25-L61","documentation":"Returned by `dive <image>` when setUI fails to install the v1 gocui UI into the application state (state.UI.Replace(ux)). Identical mechanism to error [7] on the build command: the interactive UI could not be created — usually because stdout is not a usable TTY or the terminal cannot be initialized.","triggerScenarios":"Running `dive nginx` with piped/redirected stdout (dive nginx | grep x), from a non-interactive CI shell, through docker exec without -t, or with an invalid/absent TERM variable.","commonSituations":"Trying to screenshot dive output via pipe; running dive in a cron job or GitLab/GitHub step without a pseudo-TTY; minimal container shells lacking terminfo.","solutions":["Run in an interactive terminal; for captured environments wrap with script or use a pty","Use non-interactive modes for automation: --ci for gating or --json for data instead of the TUI","export TERM=xterm-256color (and ensure terminfo is installed) in minimal environments","Read the wrapped gocui error for specifics (size, termios failures)"],"exampleFix":"# before (CI, no TTY -> UI setup fails)\ndive nginx:latest | tee out.txt\n\n# after\ndive nginx:latest --json out.json","handlingStrategy":"validation","validationCode":"# only start the TUI when stdout is a terminal\n[ -t 1 ] && dive myimage:latest || dive myimage:latest --ci","typeGuard":null,"tryCatchPattern":"if err := setUI(app, opts.Application); err != nil {\n    if !isatty.IsTerminal(os.Stdout.Fd()) {\n        // rerun decision: use --ci/--json mode instead of interactive UI\n    }\n    return fmt.Errorf(\"failed to set UI: %w\", err)\n}","preventionTips":["Branch on TTY availability before choosing interactive vs CI mode","Set TERM and install terminfo in minimal environments","Prefer --json for any scripted capture of dive data"],"tags":["ui","tty","terminal","gocui","root-command"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}