{"record":{"id":"6499ff40fa42df31","repo":"atuinsh/atuin","slug":"interactive-mode-requires-a-terminal","errorCode":null,"errorMessage":"Interactive mode requires a terminal","messagePattern":"Interactive mode requires a terminal","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/search/interactive.rs","lineNumber":1528,"sourceCode":"        // On Windows, use CONOUT$ which is the equivalent of /dev/tty, but this\n        // requires setting the current console output code page to UTF-8 for the\n        // TUI to render properly. We'll set it back to its previous value upon exit.\n        #[cfg(windows)]\n        {\n            let file = std::fs::File::options().read(true).write(true).open(\"CONOUT$\")?;\n\n            let initial_console_output_cp = unsafe { GetConsoleOutputCP() };\n            if initial_console_output_cp != Self::CP_UTF8 {\n                unsafe {\n                    SetConsoleOutputCP(Self::CP_UTF8);\n                }\n            }\n\n            Ok(TerminalWriter::ConOut(std::io::LineWriter::new(file), initial_console_output_cp))\n        }\n\n        #[cfg(not(any(unix, windows)))]\n        Err(std::io::Error::new(\n            std::io::ErrorKind::Unsupported,\n            \"Interactive mode requires a terminal\",\n        ))\n    }\n}\n\nimpl Write for TerminalWriter {\n    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {\n        match self {\n            TerminalWriter::Stdout(stdout) => stdout.write(buf),\n            #[cfg(unix)]\n            TerminalWriter::Tty(file) => file.write(buf),\n            #[cfg(windows)]\n            TerminalWriter::ConOut(writer, _) => writer.write(buf),\n        }\n    }\n\n    fn flush(&mut self) -> std::io::Result<()> {","sourceCodeStart":1510,"sourceCodeEnd":1546,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin/src/command/client/search/interactive.rs#L1510-L1546","documentation":"When building the interactive search UI's terminal writer, platforms that are neither unix nor windows have no supported console implementation, so `new` returns an io::Error with kind Unsupported and message \"Interactive mode requires a terminal\". It means the interactive full-screen search cannot run on this platform (or without a TTY abstraction).","triggerScenarios":"Running atuin's interactive search (`atuin search` interactive mode / Ctrl-R) on a target compiled for a platform other than unix or windows (cfg not(any(unix, windows))), where the TerminalWriter setup is unimplemented.","commonSituations":"Building/running atuin on wasm,Redox, or another exotic target; embedding atuin on an unsupported platform and invoking interactive mode instead of non-interactive search.","solutions":["Use non-interactive search instead (`atuin search --search-mode <mode>` without interactive TUI, or pipe output).","Run on a supported platform (unix or windows) where the terminal writer is implemented.","If you maintain the port, implement a TerminalWriter variant for the platform behind the same cfg gate.","Force interactive off via configuration/scripting so the Unsupported path is never taken."],"exampleFix":"// before\natuin search -i  // interactive, unsupported on this platform\n\n// after\natuin search --limit 10  // non-interactive listing works everywhere","handlingStrategy":"fallback","validationCode":"// gate interactive mode on supported platforms at runtime\n#[cfg(any(unix, windows))]\nlet interactive_ok = true;\n#[cfg(not(any(unix, windows)))]\nlet interactive_ok = false;","typeGuard":null,"tryCatchPattern":"match setup_terminal() {\n    Ok(w) => run_interactive(w),\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => {\n        eprintln!(\"interactive mode unavailable here; falling back to list output\");\n        run_non_interactive()?;\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["On non-unix/windows targets, always invoke non-interactive search commands.","Provide a platform check before offering interactive mode in embedded builds.","Detect the Unsupported io::ErrorKind and degrade gracefully rather than propagating."],"tags":["terminal","platform","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}