{"record":{"id":"5ff9331bd14c9d6e","repo":"denoland/deno","slug":"failed-to-create-editor","errorCode":null,"errorMessage":"Failed to create editor.","messagePattern":"Failed to create editor\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/repl/editor.rs","lineNumber":606,"sourceCode":"#[derive(Clone)]\npub struct ReplEditor {\n  inner: Arc<Mutex<Editor<EditorHelper, rustyline::history::FileHistory>>>,\n  history_file_path: Option<PathBuf>,\n  errored_on_history_save: Arc<AtomicBool>,\n  should_exit_on_interrupt: Arc<AtomicBool>,\n}\n\nimpl ReplEditor {\n  pub fn new(\n    helper: EditorHelper,\n    history_file_path: Option<PathBuf>,\n  ) -> Result<Self, AnyError> {\n    let editor_config = Config::builder()\n      .completion_type(CompletionType::List)\n      .build();\n\n    let mut editor =\n      Editor::with_config(editor_config).expect(\"Failed to create editor.\");\n    editor.set_helper(Some(helper));\n    if let Some(history_file_path) = &history_file_path {\n      editor.load_history(history_file_path).unwrap_or(());\n    }\n    editor.bind_sequence(\n      KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),\n      EventHandler::Simple(Cmd::Newline),\n    );\n    editor.bind_sequence(\n      KeyEvent(KeyCode::Tab, Modifiers::NONE),\n      EventHandler::Conditional(Box::new(TabEventHandler)),\n    );\n    let should_exit_on_interrupt = Arc::new(AtomicBool::new(false));\n    editor.bind_sequence(\n      KeyEvent(KeyCode::Char('r'), Modifiers::CTRL),\n      EventHandler::Conditional(Box::new(ReverseSearchHistoryEventHandler {\n        should_exit_on_interrupt: should_exit_on_interrupt.clone(),\n      })),","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/repl/editor.rs#L588-L624","documentation":"When `deno` starts without a script it builds a line editor (rustyline) for the REPL with list completions, history, and custom key bindings. Editor::with_config() is expected to always succeed; if the underlying terminal cannot be initialized, .expect() panics with 'Failed to create editor.' and the REPL dies at startup.","triggerScenarios":"Launching the Deno REPL (`deno` or `deno repl`) where terminal setup fails: stdin/stdout not connected to a TTY (piped or closed), a missing or wrong TERM with no terminfo database, or an unsupported console.","commonSituations":"Accidentally running `deno` in scripts/CI where stdin is /dev/null or a pipe; minimal Docker images without ncurses terminfo; starting the REPL from cron, services, or non-interactive SSH commands.","solutions":["Run the REPL in a real interactive terminal, not with redirected stdin","Use `deno run script.ts` or `deno eval \"...\"` for non-interactive use instead of the REPL","Fix TERM (e.g. export TERM=xterm) and install terminfo (ncurses-base / ncurses-term)","Pipe scripts explicitly: deno run - < script.ts"],"exampleFix":"# before\ndeno < input.txt   # REPL starts with piped stdin -> editor creation can fail\n\n# after\ndeno run - < input.txt","handlingStrategy":"validation","validationCode":"if (!Deno.isatty(Deno.stdin.rid)) {\n  console.error(\"no TTY on stdin; use `deno run -` instead of the REPL\");\n  Deno.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never start the REPL from scripts, pipes, or cron; use deno run/eval","Ensure TERM is set and terminfo is installed in minimal containers","Wrap interactive launchers with a TTY check and a helpful fallback command"],"tags":["repl","terminal","panic","rustyline","tty"],"backgroundTag":"terminal-initialization-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}