From 83960c7814d3fac45cd03cdcac782c5b3677e6b2 Mon Sep 17 00:00:00 2001 From: Kate Temkin Date: Sun, 5 May 2024 16:46:41 -0600 Subject: [PATCH] fix: provide a convenient message if TERM isn't set --- src/cli/subcommand/install.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cli/subcommand/install.rs b/src/cli/subcommand/install.rs index 73cdfe2..aec2d81 100644 --- a/src/cli/subcommand/install.rs +++ b/src/cli/subcommand/install.rs @@ -1,4 +1,5 @@ use std::{ + io::{stdout, Write}, os::unix::prelude::PermissionsExt, path::{Path, PathBuf}, process::ExitCode, @@ -80,6 +81,22 @@ impl CommandExecute for Install { explain, } = self; + // Get our terminal object, explaining what to do if it's not there. + let term = + term::terminfo::TerminfoTerminal::new(stdout()); + if term.is_none() && !no_confirm { + eprintln!( + "{}", + format!("\ + \n\ + Couldn't figure out which terminal you're using -- check the value of the $TERM variable.\n\n\ + If you're using an interactive terminal, it's probably safe to set TERM to \"xterm\",\n\ + by e.g. running 'export TERM=xterm'.\n\ + ").red() + ); + interaction::clean_exit_with_message("Couldn't get the terminal! Aborting.").await; + } + ensure_root()?; let existing_receipt: Option = match Path::new(RECEIPT_LOCATION).exists() {