From 033741246cdb8c653cc3bf9a6cc12f23dac08e6e Mon Sep 17 00:00:00 2001 From: Johann Hofmann Date: Sat, 2 Jul 2016 22:19:04 +0200 Subject: [PATCH] Show more helpful error if rustfmt is not in PATH. This fixes #1071. --- src/bin/cargo-fmt.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bin/cargo-fmt.rs b/src/bin/cargo-fmt.rs index 909d62b20f8..7bd61dd1661 100644 --- a/src/bin/cargo-fmt.rs +++ b/src/bin/cargo-fmt.rs @@ -204,6 +204,16 @@ fn format_files(files: &Vec, .stdout(stdout) .args(files) .args(fmt_args) - .spawn()); + .spawn() + .map_err(|e| { + match e.kind() { + std::io::ErrorKind::NotFound => { + std::io::Error::new(std::io::ErrorKind::Other, + "Could not run rustfmt, please make sure it is in your \ + PATH.") + } + _ => e, + } + })); command.wait() }