Skip to content

Commit

Permalink
feat: tolerate pixi file error
Browse files Browse the repository at this point in the history
  • Loading branch information
jvenant committed Nov 11, 2024
1 parent 5ab7fac commit eb7e0fb
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,28 @@ pub(crate) fn write_environment_file(
.parent()
.expect("There should already be a conda-meta folder");

std::fs::create_dir_all(parent).into_diagnostic()?;
match std::fs::create_dir_all(parent).into_diagnostic() {
Ok(_) => {
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()
),
}
}
Err(e) => tracing::debug!(
"Unable to create conda-meta folder to: {:?} => {:?}",
path,
e.root_cause().to_string()
),
}

// 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)
}
Expand Down

0 comments on commit eb7e0fb

Please sign in to comment.