diff --git a/Cargo.lock b/Cargo.lock index c322c4e..4820dab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "csm" -version = "0.1.0-alpha3" +version = "0.1.0-alpha4" dependencies = [ "assert_cmd", "bzip2", diff --git a/Cargo.toml b/Cargo.toml index 0fe19fc..f566e89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "csm" -version = "0.1.0-alpha3" +version = "0.1.0-alpha4" edition = "2024" [lints.clippy] diff --git a/src/micromamba/mod.rs b/src/micromamba/mod.rs index 91ae5c3..e141510 100644 --- a/src/micromamba/mod.rs +++ b/src/micromamba/mod.rs @@ -39,7 +39,7 @@ fn block_on_child_exit(child: &mut std::process::Child) -> MicromambaResult { } fn exec_micromamba(cmd: &mut Command, stream_output: bool) -> MicromambaResult { - if stream_output { + let result = if stream_output { match cmd.spawn() { Ok(mut child) => block_on_child_exit(&mut child), Err(e) if e.kind() == io::ErrorKind::NotFound => { @@ -65,7 +65,22 @@ fn exec_micromamba(cmd: &mut Command, stream_output: bool) -> MicromambaResult { MicromambaResult::CouldNotRun } } + }; + + if cfg!(windows) + && result + .exit_status() + .and_then(|s| s.code()) + .is_some_and(|s| s == 0xc0000135u32 as i32) + { + error!("Windows reported a missing DLL required to run micromamba"); + error!("This error can very likely be solved by installing the VC++ runtime libraries"); + error!( + "See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-supported-redistributable-version for more information" + ); } + + result } impl<'a> Micromamba<'a> { diff --git a/src/micromamba/result.rs b/src/micromamba/result.rs index 91048d7..f692def 100644 --- a/src/micromamba/result.rs +++ b/src/micromamba/result.rs @@ -39,6 +39,14 @@ impl MicromambaResult { _ => ExitCode::FAILURE, } } + + pub fn exit_status(&self) -> Option { + match self { + Self::StreamedOutput(exit_status) => Some(*exit_status), + Self::CapturedOutput(output) => Some(output.status), + _ => None, + } + } } impl From for Result<(), ExitCode> {