Fix first startup on macOS

This commit is contained in:
Uber Veng
2026-05-29 12:58:15 +07:00
parent b0407d6519
commit a93f3ad9f6
3 changed files with 8 additions and 10 deletions

View File

@@ -172,17 +172,15 @@ async fn run_exec(
fn prompt_first_endpoint() -> Result<(String, String)> {
use std::io::{BufRead, BufReader, Write};
// Open /dev/tty directly so input works even when launched via `curl | bash`
// (where stdin is the pipe carrying the script, not the keyboard).
let tty = std::fs::OpenOptions::new()
.read(true)
.write(true)
.open("/dev/tty")
// Open /dev/tty read-only for keyboard input so the wizard works even when
// stdin is a pipe (e.g. `curl | bash`). Writing goes through stdout so we
// don't touch the terminal's write-side state before crossterm takes over.
let tty_in = std::fs::File::open("/dev/tty")
.map_err(|e| anyhow::anyhow!(
"Не удалось открыть терминал ({e}). Запустите ostiary напрямую."
))?;
let mut out = tty.try_clone()?;
let mut reader = BufReader::new(tty);
let mut reader = BufReader::new(tty_in);
let mut out = std::io::stdout();
writeln!(out)?;
writeln!(out, " ╔══════════════════════════════════╗")?;