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 1
1
//! toolchain installation logic
2
2
3
3
use anyhow:: Context as _;
4
+ use crossterm:: tty:: IsTty as _;
5
+
6
+ use crate :: user_output;
4
7
5
8
/// Use `rustup` to install the toolchain and components, if not already installed.
6
9
///
@@ -103,9 +106,17 @@ fn get_consent_for_toolchain_install(
103
106
if skip_toolchain_install_consent {
104
107
return Ok ( ( ) ) ;
105
108
}
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
+
106
117
log:: debug!( "asking for consent to install the required toolchain" ) ;
107
118
crossterm:: terminal:: enable_raw_mode ( ) . context ( "enabling raw mode" ) ?;
108
- crate :: user_output!( "{prompt} [y/n]: \n " ) ;
119
+ crate :: user_output!( "{prompt} [y/n]: " ) ;
109
120
let mut input = crossterm:: event:: read ( ) . context ( "reading crossterm event" ) ?;
110
121
111
122
if let crossterm:: event:: Event :: Key ( crossterm:: event:: KeyEvent {
You can’t perform that action at this time.
0 commit comments