From eb7e0fb8ba5435812c322a7f6d030815fbc3b92a Mon Sep 17 00:00:00 2001 From: Johan Venant Date: Mon, 11 Nov 2024 15:13:14 +0100 Subject: [PATCH] feat: tolerate pixi file error --- src/environment.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/environment.rs b/src/environment.rs index 77e2ecd9af..8e9e9dbc63 100644 --- a/src/environment.rs +++ b/src/environment.rs @@ -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) }