{"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":1467,"sourceCode":"                .read(true)\n                .write(true)\n                .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(\n                std::io::LineWriter::new(file),\n                initial_console_output_cp,\n            ))\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":1449,"sourceCodeEnd":1485,"githubUrl":"https://github.com/atuinsh/atuin/blob/202f6ad98ee0da165c35cdb2afbc5b13d6ab81a1/crates/atuin/src/command/client/search/interactive.rs#L1449-L1485","documentation":"Returned by TerminalWriter::new in interactive search when Atuin is compiled for a target that is neither unix nor windows (the #[cfg(not(any(unix, windows)))] arm at interactive.rs:1466). Interactive mode needs a terminal: stdout when it is a TTY, /dev/tty on unix, or CONOUT$ on Windows; with no platform backend available it fails with io::ErrorKind::Unsupported. This is effectively a build/platform configuration problem, not a runtime environment one.","triggerScenarios":"Building the atuin binary for an exotic target (wasm32, redox, etc.) where none of the cfg(unix)/cfg(windows) terminal backends compile, then invoking `atuin search -i` (interactive mode), which constructs TerminalWriter.","commonSituations":"Cross-compiling Atuin to a Tier-3 target; running in a sandbox/wasm environment that maps neither unix nor windows cfg flags; developers porting Atuin hitting the compile-time gap during first run on a new OS.","solutions":["Run interactive search on a supported platform (unix or windows builds of Atuin)","Use non-interactive search (`atuin search <query>`) which prints results to stdout and never builds a TerminalWriter","If porting, implement a TerminalWriter backend for the target (e.g. open the platform's controlling terminal) behind a new cfg gate","Catch io::ErrorKind::Unsupported in embedding code and degrade to non-interactive output"],"exampleFix":"// before\nlet writer = TerminalWriter::new()?;\n\n// after\nlet writer = TerminalWriter::new().or_else(|e| {\n    if e.kind() == std::io::ErrorKind::Unsupported {\n        // fall back to non-interactive output on this platform\n    }\n    Err(e)\n})?;","handlingStrategy":"fallback","validationCode":"// Detect the unsupported case before launching the TUI\nlet interactive_ok = cfg!(any(unix, windows));\nif !interactive_ok { /* run non-interactive search path instead */ }","typeGuard":null,"tryCatchPattern":"match TerminalWriter::new() {\n    Ok(w) => { /* run TUI */ }\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => {\n        // no terminal backend on this platform: fall back to plain output\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Only target unix or windows platforms when you need interactive search","In scripts and embeddings, prefer non-interactive `atuin search <query>`","Gate interactive mode behind a cfg!(any(unix, windows)) check in porting efforts","Contribute a TerminalWriter backend before shipping a new platform build"],"tags":["terminal","platform","tui","unsupported","rust","atuin"],"backgroundTag":"unsupported-platform","analyzedSha":"202f6ad98ee0da165c35cdb2afbc5b13d6ab81a1","analyzedAt":"2026-08-16T19:30:24.731Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}