denoland/deno · error
Failed to create editor.
Error message
Failed to create editor.
What it means
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.
Source
Thrown at cli/tools/repl/editor.rs:606
#[derive(Clone)]
pub struct ReplEditor {
inner: Arc<Mutex<Editor<EditorHelper, rustyline::history::FileHistory>>>,
history_file_path: Option<PathBuf>,
errored_on_history_save: Arc<AtomicBool>,
should_exit_on_interrupt: Arc<AtomicBool>,
}
impl ReplEditor {
pub fn new(
helper: EditorHelper,
history_file_path: Option<PathBuf>,
) -> Result<Self, AnyError> {
let editor_config = Config::builder()
.completion_type(CompletionType::List)
.build();
let mut editor =
Editor::with_config(editor_config).expect("Failed to create editor.");
editor.set_helper(Some(helper));
if let Some(history_file_path) = &history_file_path {
editor.load_history(history_file_path).unwrap_or(());
}
editor.bind_sequence(
KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),
EventHandler::Simple(Cmd::Newline),
);
editor.bind_sequence(
KeyEvent(KeyCode::Tab, Modifiers::NONE),
EventHandler::Conditional(Box::new(TabEventHandler)),
);
let should_exit_on_interrupt = Arc::new(AtomicBool::new(false));
editor.bind_sequence(
KeyEvent(KeyCode::Char('r'), Modifiers::CTRL),
EventHandler::Conditional(Box::new(ReverseSearchHistoryEventHandler {
should_exit_on_interrupt: should_exit_on_interrupt.clone(),
})),View on GitHub (pinned to 9ad36f7a2c)
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
Example fix
# before deno < input.txt # REPL starts with piped stdin -> editor creation can fail # after deno run - < input.txt
Defensive patterns
Strategy: validation
Validate before calling
if (!Deno.isatty(Deno.stdin.rid)) {
console.error("no TTY on stdin; use `deno run -` instead of the REPL");
Deno.exit(1);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/5ff9331bd14c9d6e.
Report an issue: GitHub.