Skip to content

Commit ee8bc39

Browse files
committed
Windows: Try to give a nicer error if missing VC++
Without the redistributable libs, micromamba can't run. Tell the user where to get it.
1 parent 8ad270e commit ee8bc39

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/micromamba/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn block_on_child_exit(child: &mut std::process::Child) -> MicromambaResult {
3939
}
4040

4141
fn exec_micromamba(cmd: &mut Command, stream_output: bool) -> MicromambaResult {
42-
if stream_output {
42+
let result = if stream_output {
4343
match cmd.spawn() {
4444
Ok(mut child) => block_on_child_exit(&mut child),
4545
Err(e) if e.kind() == io::ErrorKind::NotFound => {
@@ -65,7 +65,22 @@ fn exec_micromamba(cmd: &mut Command, stream_output: bool) -> MicromambaResult {
6565
MicromambaResult::CouldNotRun
6666
}
6767
}
68+
};
69+
70+
if cfg!(windows)
71+
&& result
72+
.exit_status()
73+
.and_then(|s| s.code())
74+
.is_some_and(|s| s == 0xc0000135u32 as i32)
75+
{
76+
error!("Windows reported a missing DLL required to run micromamba");
77+
error!("This error can very likely be solved by installing the VC++ runtime libraries");
78+
error!(
79+
"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-supported-redistributable-version for more information"
80+
);
6881
}
82+
83+
result
6984
}
7085

7186
impl<'a> Micromamba<'a> {

src/micromamba/result.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ impl MicromambaResult {
3939
_ => ExitCode::FAILURE,
4040
}
4141
}
42+
43+
pub fn exit_status(&self) -> Option<ExitStatus> {
44+
match self {
45+
Self::StreamedOutput(exit_status) => Some(*exit_status),
46+
Self::CapturedOutput(output) => Some(output.status),
47+
_ => None,
48+
}
49+
}
4250
}
4351

4452
impl From<MicromambaResult> for Result<(), ExitCode> {

0 commit comments

Comments
 (0)