{"record":{"id":"2e451909fa31c609","repo":"lima-vm/lima","slug":"failed-to-open-tui-w-preserving-guest-synced-wo","errorCode":null,"errorMessage":"failed to open TUI: %w; preserving guest synced workdir at %s","messagePattern":"failed to open TUI: %w; preserving guest synced workdir at (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":615,"sourceCode":"\t\treturn fmt.Errorf(\"failed to create temporary directory: %w; preserving guest synced workdir at %s\", err, destRsyncDir)\n\t}\n\tdefer func() {\n\t\tif err := os.RemoveAll(baseDir); err != nil {\n\t\t\tlogrus.WithError(err).Warnf(\"Failed to clean up temporary directory %s\", baseDir)\n\t\t}\n\t}()\n\thostTmpDest := filepath.Join(baseDir, filepath.Base(hostCurrentDir))\n\terr = os.MkdirAll(hostTmpDest, 0o755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temporary directory: %w; preserving guest synced workdir at %s\", err, destRsyncDir)\n\t}\n\n\trsyncToTempDir := false\n\n\tfor {\n\t\tans, err := uiutil.Select(message, options)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open TUI: %w; preserving guest synced workdir at %s\", err, destRsyncDir)\n\t\t}\n\n\t\tswitch ans {\n\t\tcase 0: // Yes\n\t\t\treturn rsyncBack()\n\t\tcase 1: // No\n\t\t\tcleanupGuestWorkdir = true\n\t\t\tlogrus.Info(\"Skipping syncing back the changes to host.\")\n\t\t\treturn nil\n\t\tcase 2: // View the changed contents\n\t\t\tvar diffCmd *exec.Cmd\n\t\t\tif _, err := exec.LookPath(\"diff\"); err != nil {\n\t\t\t\tlogrus.WithError(err).Warn(\"`diff` not found; showing rsync dry-run output only\")\n\t\t\t} else {\n\t\t\t\tdiffCmd = exec.CommandContext(ctx, \"diff\", \"-ruN\", \"--color=always\", hostCurrentDir, hostTmpDest)\n\t\t\t\tif !rsyncToTempDir {\n\t\t\t\t\tpaths := []string{\n\t\t\t\t\t\tremoteSource,","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L597-L633","documentation":"The interactive \"Accept the changes?\" menu is rendered with uiutil.Select, which requires a usable terminal. If the TUI cannot be opened (stdin/stdout not an interactive terminal despite the tty flag, terminal init failure, or interrupted input), this error is returned and the guest synced workdir is preserved at destRsyncDir.","triggerScenarios":"Running `limactl shell` with `--tty` forced (or tty detection passing) but stdout/stdin is actually redirected, closed, or attached to a non-terminal (CI runner, script with pty flag, detached process); terminal too small or unsupported TERM causing the select UI to fail.","commonSituations":"CI systems that emulate a TTY but break interactive prompts; running limactl inside tmux/screen with odd TERM values; piping limactl output while --tty is set; window too small for the bubbletea-style prompt.","solutions":["Recover your changes from the preserved guest workdir: `limactl shell <instance>` and copy files out of destRsyncDir.","Run without forced tty so the non-interactive path syncs back automatically (remove --tty / run with piped stdio).","Fix the terminal environment: use a real interactive terminal, set a supported TERM (e.g. xterm-256color), enlarge the window.","If in CI, avoid --tty and accept that changes sync back without prompting."],"exampleFix":"// before\nlimactl shell --tty default\n// after: let lima detect the terminal instead of forcing tty\nlimactl shell default","handlingStrategy":"fallback","validationCode":"tty -s && tty -s <&1 && echo 'interactive terminal available' || echo 'not a real TTY: run without --tty'","typeGuard":null,"tryCatchPattern":"// choose behavior based on TTY availability\nif tty -s; then limactl shell default; else limactl shell default < /dev/null; fi","preventionTips":["Don't force --tty in scripts or CI.","Use a real terminal with a standard TERM value (xterm-256color).","Ensure the terminal window is large enough for interactive prompts.","Fall back to non-interactive mode when stdin/stdout is redirected."],"tags":["tui","terminal","interactive"],"backgroundTag":"tui-not-a-terminal","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}