Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tolerate pixi file error #2457

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading