File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 11//! toolchain installation logic
22
33use anyhow:: Context as _;
4+ use crossterm:: tty:: IsTty as _;
5+
6+ use crate :: user_output;
47
58/// Use `rustup` to install the toolchain and components, if not already installed.
69///
@@ -103,9 +106,17 @@ fn get_consent_for_toolchain_install(
103106 if skip_toolchain_install_consent {
104107 return Ok ( ( ) ) ;
105108 }
109+
110+ if !std:: io:: stdout ( ) . is_tty ( ) {
111+ user_output ! ( "No TTY detected so can't ask for consent to install Rust toolchain." ) ;
112+ log:: error!( "Attempted to ask for consent when there's no TTY" ) ;
113+ #[ expect( clippy:: exit, reason = "can't ask for user consent if there's no TTY" ) ]
114+ std:: process:: exit ( 1 ) ;
115+ }
116+
106117 log:: debug!( "asking for consent to install the required toolchain" ) ;
107118 crossterm:: terminal:: enable_raw_mode ( ) . context ( "enabling raw mode" ) ?;
108- crate :: user_output!( "{prompt} [y/n]: \n " ) ;
119+ crate :: user_output!( "{prompt} [y/n]: " ) ;
109120 let mut input = crossterm:: event:: read ( ) . context ( "reading crossterm event" ) ?;
110121
111122 if let crossterm:: event:: Event :: Key ( crossterm:: event:: KeyEvent {
You can’t perform that action at this time.
0 commit comments