Use which instead of running rustc --version
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -10,7 +10,7 @@ use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::io::{self, prelude::*};
|
||||
use std::path::Path;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, RecvTimeoutError};
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -100,7 +100,7 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
if !rustc_exists() {
|
||||
if which::which("rustc").is_err() {
|
||||
println!("We cannot find `rustc`.");
|
||||
println!("Try running `rustc --version` to diagnose your problem.");
|
||||
println!("For instructions on how to install Rust, check the README.");
|
||||
@@ -403,18 +403,6 @@ fn watch(
|
||||
}
|
||||
}
|
||||
|
||||
fn rustc_exists() -> bool {
|
||||
Command::new("rustc")
|
||||
.args(["--version"])
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.stdin(Stdio::null())
|
||||
.spawn()
|
||||
.and_then(|mut child| child.wait())
|
||||
.map(|status| status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
const DEFAULT_OUT: &str = r#"Thanks for installing Rustlings!
|
||||
|
||||
Is this your first time? Don't worry, Rustlings was made for beginners! We are
|
||||
|
||||
Reference in New Issue
Block a user