Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/cargo-gpu/src/install_toolchain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! toolchain installation logic

use anyhow::Context as _;
use crossterm::tty::IsTty as _;

use crate::user_output;

/// Use `rustup` to install the toolchain and components, if not already installed.
///
Expand Down Expand Up @@ -103,9 +106,17 @@ fn get_consent_for_toolchain_install(
if skip_toolchain_install_consent {
return Ok(());
}

if !std::io::stdout().is_tty() {
user_output!("No TTY detected so can't ask for consent to install Rust toolchain.");
log::error!("Attempted to ask for consent when there's no TTY");
#[expect(clippy::exit, reason = "can't ask for user consent if there's no TTY")]
std::process::exit(1);
}

log::debug!("asking for consent to install the required toolchain");
crossterm::terminal::enable_raw_mode().context("enabling raw mode")?;
crate::user_output!("{prompt} [y/n]: \n");
crate::user_output!("{prompt} [y/n]: ");
let mut input = crossterm::event::read().context("reading crossterm event")?;

if let crossterm::event::Event::Key(crossterm::event::KeyEvent {
Expand Down