Skip to content

Commit

Permalink
chore: add more info to an failure of activation (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored Feb 27, 2024
1 parent fbcbaae commit 12b8dc3
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::collections::HashMap;
use itertools::Itertools;
use miette::IntoDiagnostic;
use rattler_conda_types::Platform;
use rattler_shell::activation::ActivationError::FailedToRunActivationScript;
use rattler_shell::{
activation::{ActivationError, ActivationVariables, Activator, PathModificationBehavior},
shell::ShellEnum,
Expand Down Expand Up @@ -128,7 +129,7 @@ pub async fn run_activation(
))
})?;

let activator_result = tokio::task::spawn_blocking(move || {
let activator_result = match tokio::task::spawn_blocking(move || {
// Run and cache the activation script
activator.run_activation(ActivationVariables {
// Get the current PATH variable
Expand All @@ -143,7 +144,35 @@ pub async fn run_activation(
})
.await
.into_diagnostic()?
.into_diagnostic()?;
{
Ok(activator) => activator,
Err(e) => {
match e {
FailedToRunActivationScript {
script,
stdout,
stderr,
status,
} => {
return Err(miette::miette!(format!(
"Failed to run activation script for {:?}. Status: {}. Stdout: {}. Stderr: {}. Script: {}",
environment.name(), // Make sure `environment` is accessible here
status,
stdout,
stderr,
script,
)));
}
_ => {
// Handle other activation errors
return Err(miette::miette!(format!(
"An activation error occurred: {:?}",
e
)));
}
}
}
};

Ok(activator_result)
}
Expand Down

0 comments on commit 12b8dc3

Please sign in to comment.