Skip to content

Commit

Permalink
feat: tolerate pixi file error (#2457)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvenant authored Nov 12, 2024
1 parent 689cf9d commit 5d37dcf
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,27 @@ pub(crate) fn write_environment_file(
.parent()
.expect("There should already be a conda-meta folder");

std::fs::create_dir_all(parent).into_diagnostic()?;

// Using json as it's easier to machine read it.
let contents = serde_json::to_string_pretty(&env_file).into_diagnostic()?;
std::fs::write(&path, contents).into_diagnostic()?;

tracing::debug!("Wrote environment file to: {:?}", path);

Ok(path)
match std::fs::create_dir_all(parent).into_diagnostic() {
Ok(_) => {
// Using json as it's easier to machine read it.
let contents = serde_json::to_string_pretty(&env_file).into_diagnostic()?;
match std::fs::write(&path, contents).into_diagnostic() {
Ok(_) => {
tracing::debug!("Wrote environment file to: {:?}", path);
}
Err(e) => tracing::debug!(
"Unable to write environment file to: {:?} => {:?}",
path,
e.root_cause().to_string()
),
};
Ok(path)
}
Err(e) => {
tracing::debug!("Unable to create conda-meta folder to: {:?}", path);
Err(e)
}
}
}

/// Reading the environment file of the environment.
Expand Down

0 comments on commit 5d37dcf

Please sign in to comment.