Skip to content

Commit b416f24

Browse files
ankddevlpil
authored andcommitted
feat: show better error when installing Git deps without Git
1 parent 5ec80a2 commit b416f24

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

compiler-cli/src/dependencies.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod dependency_manager;
33
use std::{
44
cell::RefCell,
55
collections::{HashMap, HashSet},
6+
io::ErrorKind,
67
process::Command,
78
rc::Rc,
89
time::Instant,
@@ -37,7 +38,7 @@ use crate::{
3738
TreeOptions,
3839
build_lock::{BuildLock, Guard},
3940
cli,
40-
fs::{self, ProjectIO},
41+
fs::{self, ProjectIO, get_os},
4142
http::HttpClient,
4243
text_layout::space_table,
4344
};
@@ -785,21 +786,20 @@ fn provide_local_package(
785786
}
786787

787788
fn execute_command(command: &mut Command) -> Result<std::process::Output> {
788-
let output = command.output().map_err(|error| Error::ShellCommand {
789-
program: "git".into(),
790-
reason: ShellCommandFailureReason::IoError(error.kind()),
791-
})?;
792-
if output.status.success() {
793-
Ok(output)
794-
} else {
795-
let reason = match String::from_utf8(output.stderr) {
796-
Ok(stderr) => ShellCommandFailureReason::ShellCommandError(stderr),
797-
Err(_) => ShellCommandFailureReason::Unknown,
798-
};
799-
Err(Error::ShellCommand {
800-
program: "git".into(),
801-
reason,
802-
})
789+
let result = command.output();
790+
match result {
791+
Ok(output) => Ok(output),
792+
Err(error) => Err(match error.kind() {
793+
ErrorKind::NotFound => Error::ShellProgramNotFound {
794+
program: "git".into(),
795+
os: get_os(),
796+
},
797+
798+
other => Error::ShellCommand {
799+
program: "git".into(),
800+
reason: ShellCommandFailureReason::IoError(other),
801+
},
802+
}),
803803
}
804804
}
805805

0 commit comments

Comments
 (0)